Article View: gnu.bash.bug
Article #352Re: Alias bug in BASH 1.01
From: Chet Ramey
Date: Wed, 19 Jul 1989 17:18
Date: Wed, 19 Jul 1989 17:18
45 lines
1719 bytes
1719 bytes
In article <926@pcsbst.UUCP> jkh@meepmeep.pcs.com ( Jordan K. Hubbard ) writes:
>The alias code is broken. Try the following:
>
>bash% alias retch='echo \!*'
>bash% retch foo bar blat
>!* foo bar blat
>bash%
>
>The !* should expand into the current arg list, ala csh.
>None of the other !<arg> constructs work in aliases either.
It's not a bug, it's a design decision.
The alias mechanism in bash is more akin to the way ksh does it
(rather than csh) in that it only performs simple textual substitution.
If you want the ability to use arguments, use shell functions instead.
>function setenv () {
> eval $1=$2
> export $2
>}
>
This should be
eval $1="$2"
export $1
or even
export $1="$2"
You need to quote the second argument because it will be expanded (this
example is from Brian Fox, from a discussion we were having about this):
foo="foo and bar"
setenv baz "$foo"
setenv->$2 = foo and bar
eval $1=$2 -> baz=foo and bar
NOT baz="foo and bar"
Chet Ramey
Chet Ramey "We are preparing to think about contemplating
Network Services Group, CWRU preliminary work on plans to develop a
chet@cwjcc.INS.CWRU.Edu schedule for producing the 10th Edition of
the Unix Programmers Manual." -- Andrew Hume
Technical Details
Message-ID:
<429@cwjcc.CWRU.Edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!cwjcc!kiwi!chetReferences:
<926@pcsbst.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!cwjcc!kiwi!chet From: chet@kiwi.CWRU.EDU (Chet Ramey) Newsgroups: gnu.bash.bug Subject: Re: Alias bug in BASH 1.01 Message-ID: <429@cwjcc.CWRU.Edu> Date: 19 Jul 89 17:18:51 GMT References: <926@pcsbst.UUCP> Sender: news@cwjcc.CWRU.Edu Reply-To: chet@kiwi.INS.CWRU.Edu (Chet Ramey) Organization: CWRU Andrew R. Jennings Computing Center Lines: 45