[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] BASH: how to refer to first word in command line ?
- Subject: [ale] BASH: how to refer to first word in command line ?
- From: josin at dimensional.com (josin alvistur)
- Date: Sun, 08 Jun 1997 16:18:35 -0600
In tcsh I use the following alias to 'cd' to a directory whose
path is in environment variable 'foo':
setenv foo /users/hoser/a_directory
alias foo 'cd ${\!:0}'
This is convenient, since I can have a large number of directory
names so mapped, and i only have to remember the environ var. name
to use the corresponding alias.
and I can use the environ var in the command line, to refer
to the directory:
example % pwd
/users/josin
example & ls -l $foo
OR
example % foo; ls -l
QUESTION:
How to do the same (or similar) alias setup in bash?
I tried functions, but the parameter $0 is the script's name,
*not* the function name (and it defaults to 'bash', if function
is called from the command line)
function foo { cd ${$0} } # does not work...
and, since we are here, how does one (in the general case) get
to access the function's name from inside the function ?
Thanks - josin