Imported from ../bash-1.14.7.tar.gz.
[platform/upstream/bash.git] / examples / alias-conv.sh
1 #! /bin/sh
2 #
3 # Convert Csh aliases to Bash aliases.  Adapted from a similar program
4 # supplied with zsh.
5 #
6 # This is a quick script to convert csh aliases to Bash aliases/functions.
7 # Pipe the output of csh's alias command through this; it will generate
8 # a series of alias/function definitions on stdout, suitable for
9 # processing by bash.
10 #
11 # This is not perfect, but it gets most common aliases; it should manage to
12 # cut down a lot of the busy work.
13 #
14 sed -e 's/      (\(.*\))/       \1/' >/tmp/cz$$.1
15 grep ! /tmp/cz$$.1 >/tmp/cz$$.2
16 grep -v ! /tmp/cz$$.1 >/tmp/cz$$.3
17 sed -e "s/'/'"\\\\"''"/g -e 's/^\([^    ]*\)    \(.*\)$/alias \1='"'\2'/" \
18         /tmp/cz$$.3
19 sed -e 's/![:#]*/$/g' -e 's/^\([^       ]*\)    \(.*\)$/\1 () { \2 }/' /tmp/cz$$.2
20 rm /tmp/cz$$.?
21
22 exit 0