source: vendor/bash/3.1-p17/examples/misc/aliasconv.bash

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 951 bytes
Line 
1#! /bin/bash
2#
3# aliasconv.bash - convert csh aliases to bash aliases and functions
4#
5# usage: aliasconv.bash
6#
7# Chet Ramey
8# chet@po.cwru.edu
9#
10trap 'rm -f /tmp/cb$$.?' 0 1 2 3 6 15
11
12T=$'\t'
13
14cat << \EOF >/tmp/cb$$.1
15mkalias ()
16{
17 case $2 in
18 '') echo alias ${1}="''" ;;
19 *[#\!]*)
20 comm=$(echo $2 | sed 's/\!\*/"$\@"/g
21 s/\!:\([1-9]\)/"$\1"/g
22 s/#/\#/g')
23 echo $1 \(\) "{" command "$comm" "; }"
24 ;;
25 *) echo alias ${1}=\'$(echo "${2}" | sed "s:':'\\\\'':g")\' ;;
26 esac
27}
28EOF
29
30# the first thing we want to do is to protect single quotes in the alias,
31# since they whole thing is going to be surrounded by single quotes when
32# passed to mkalias
33
34sed -e "s:':\\'\\\'\\':" -e "s/^\([a-zA-Z0-9_-]*\)$T\(.*\)$/mkalias \1 '\2'/" >>/tmp/cb$$.1
35
36$BASH /tmp/cb$$.1 | sed -e 's/\$cwd/\$PWD/g' \
37 -e 's/\$term/\$TERM/g' \
38 -e 's/\$home/\$HOME/g' \
39 -e 's/\$user/\$USER/g' \
40 -e 's/\$prompt/\$PS1/g'
41
42exit 0
Note: See TracBrowser for help on using the repository browser.