diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2007-11-12 13:06:02 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2007-11-12 13:06:02 -0800 |
commit | b7fc9e0f6d6105ba2203f219743d4b269415e84b (patch) | |
tree | ef6586dfc62798c2b17487b443864699aca55f31 /examples/misc/aliasconv.sh | |
download | vyatta-bash-b7fc9e0f6d6105ba2203f219743d4b269415e84b.tar.gz vyatta-bash-b7fc9e0f6d6105ba2203f219743d4b269415e84b.zip |
initial import from bash_3.1dfsg.orig.tar.gz
Diffstat (limited to 'examples/misc/aliasconv.sh')
-rwxr-xr-x | examples/misc/aliasconv.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/misc/aliasconv.sh b/examples/misc/aliasconv.sh new file mode 100755 index 0000000..75db077 --- /dev/null +++ b/examples/misc/aliasconv.sh @@ -0,0 +1,42 @@ +#! /bin/bash +# +# aliasconv.sh - convert csh aliases to bash aliases and functions +# +# usage: aliasconv.sh +# +# Chet Ramey +# chet@po.cwru.edu +# +trap 'rm -f /tmp/cb$$.?' 0 1 2 3 6 15 + +T=' ' + +cat << \EOF >/tmp/cb$$.1 +mkalias () +{ + case $2 in + '') echo alias ${1}="''" ;; + *[#\!]*) + comm=`echo $2 | sed 's/\\!\*/"$\@"/g + s/\\!:\([1-9]\)/"$\1"/g + s/#/\#/g'` + echo $1 \(\) "{" command "$comm" "; }" + ;; + *) echo alias ${1}=\'`echo "${2}" | sed "s:':'\\\\\\\\'':"`\' ;; + esac +} +EOF + +# the first thing we want to do is to protect single quotes in the alias, +# since they whole thing is going to be surrounded by single quotes when +# passed to mkalias + +sed -e "s:':\\'\\\'\\':" -e "s/^\([a-zA-Z0-9_-]*\)$T\(.*\)$/mkalias \1 '\2'/" >>/tmp/cb$$.1 + +sh /tmp/cb$$.1 | sed -e 's/\$cwd/\$PWD/g' \ + -e 's/\$term/\$TERM/g' \ + -e 's/\$home/\$HOME/g' \ + -e 's/\$user/\$USER/g' \ + -e 's/\$prompt/\$PS1/g' + +exit 0 |