make and change into a directory

Giles Orr gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Sat May 20 03:54:03 UTC 2006


On 5/19/06, Sy Ali <sy1234-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> I guess my question is:
> How can I make an alias do two things?

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.

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.

-- 
Giles
http://www.gilesorr.com/
gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
--
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