summaryrefslogtreecommitdiff
path: root/examples/functions/xalias.bash
blob: 88a00dc6d130939f5958016ab3f90152d82c1035 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# xalias - convert csh alias commands to bash functions
# from Mohit Aron <aron@cs.rice.edu>
# posted to usenet as <4i5p17$bnu@larry.rice.edu>
function xalias ()
{
	if [ "x$2" = "x" ] 
	then
		declare -f $1
	else
		case $2 in
		*[#\!]*)
			comm=$(echo $2 | sed  's/\\!\*/\"$\@\"/g
					       s/\\!:\([1-9]\)/\"$\1\"/g
				               s/#/\\#/g')
			;;
		*)
			comm="$2 \"\$@\"" ;;
		esac

		eval function $1 \(\) "{" command "$comm"  "; }"
	fi
}