Arg passing to alias in BASH

Arg passing to alias in BASH

Post by Scott Galamb » Thu, 01 Jun 1995 04:00:00



I was wonderin if anyone knew how to get the command line arguments when
the command typed is an alias under BASH.

For instance in csh " alias test 'cd \!:1; ls' "(sumthing like that) would
pass the first argument in "test /etc" to the cd command, change to /etc and
then do the ls in that directory.

How would one do this with bash?  Thanks for any help.

 
 
 

Arg passing to alias in BASH

Post by B.A.McCau.. » Fri, 09 Jun 1995 04:00:00



>Newsgroups: comp.os.linux.misc

Not a Linux question.

Quote:>I was wonderin if anyone knew how to get the command line arguments when
>the command typed is an alias under BASH.

Don't use alias, use functions.

Quote:>For instance in csh " alias test 'cd \!:1; ls' "(sumthing like that) would
>pass the first argument in "test /etc" to the cd command, change to /etc and
>then do the ls in that directory.

For Gods sake don't redefile "test"!

Quote:>How would one do this with bash?  Thanks for any help.

test() { cd $1; ls }
--

 .  _\\__[oo       from       | Phones: +44 121 471 3789 (home)

.  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37
 # ll  l\\  ~~~~ ~   ~ ~    ~ |         A1 93 FE EA BE E3 2A 91


 
 
 

1. Arg passing to alias in BASH

I was wonderin if anyone knew how to get the command line arguments when
the command typed is an alias under BASH.

For instance in csh " alias test 'cd \!:1; ls' "(sumthing like that) would
pass the first argument in "test /etc" to the cd command, change to /etc and
then do the ls in that directory.

How would one do this with bash?  Thanks for any help.

2. (n)curses, Lynx Slang. Where? How???

3. silo overflow

4. Cygwin:Bash: Preserve '\' in cmdline arg to pass to subshell?

5. Can't get netscape-dynmotif to run under RedHat 6.2

6. BASH BASH BASH BASH BASH BASH BASH BASH BASH BASH

7. tcpdump on SCO ?

8. How to pass .alias definitions to bash?

9. pass arg to E menu file entry

10. How to pass multiple words as one arg in csh

11. driver: indirect ioctl arg passing

12. Bourne shell env setting and arg passing