aboutsummaryrefslogtreecommitdiffstats
path: root/examples/functions
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>1997-06-05 14:59:13 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:50 +0000
commitd166f048818e10cf3799aa24a174fb22835f1acc (patch)
tree1ca27f9243900f8b236d0cde6a3862002aea9e19 /examples/functions
parentccc6cda312fea9f0468ee65b8f368e9653e1380b (diff)
downloadandroid_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.gz
android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.bz2
android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.zip
Imported from ../bash-2.01.tar.gz.
Diffstat (limited to 'examples/functions')
-rw-r--r--examples/functions/xalias.bash21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/functions/xalias.bash b/examples/functions/xalias.bash
new file mode 100644
index 0000000..29e8bfb
--- /dev/null
+++ b/examples/functions/xalias.bash
@@ -0,0 +1,21 @@
+# 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
+ echo $2 | egrep -q '(\!|#)'
+ if [ $? -eq 0 ]
+ then
+ comm=$(echo $2 | sed 's/\\!\*/\"$\@\"/g
+ s/\\!:\([1-9]\)/\"$\1\"/g
+ s/#/\\#/g')
+ else
+ comm="$2 \"\$@\""
+ fi
+ eval function $1 \(\) "{" command "$comm" "; }"
+ fi
+}