make and change into a directory

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue May 23 16:36:43 UTC 2006


On Fri, May 19, 2006 at 11:54:03PM -0400, Giles Orr wrote:
> Good question! Fun for the whole family ...
> 
> $ alias a2e="echo -$1-; echo _$1_"
> $ a2e blah
> --
> __ blah
> 
> Holy crap, what happened there?  If anyone can answer that, I'd really
> like to know, because that's seriously bizarre.  Hmm - in light of the
> next paragraph ... perhaps what happens is that it ignores the
> argument entirely, echoes the dashes and underscores, and then drops
> the argument just because it was hanging around?  Weird.

Well: a2e blaha
Expand alias     -> echo -$1-; echo _$1_ blah 
Expand variables -> echo --; echo __ blah
Execute commands -> --\n__ blah\n

> In the bash man page it says "There is no mechanism for using
> arguments in the replacement text.   If arguments  are  needed,  a
> shell function should be used (see FUNCTIONS below)."  I took the
> hint:
> 
> $ function f2e () { echo -$1-; echo _$1_; }
> $ f2e blah
> -blah-
> _blah_
> 
> Success?  "function mcd () { mkdir $1; cd $1; }" does appear to work
> as requested.  Please note that the trailing semicolon is required.

The function makes sense since it takes arguments, which the alias does
not.

--
Len Sorensen
RuggedCom
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list