[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Handy Bash alias script



Wesley J. Landaker(wjl@icecavern.net) is reported to have said:
> On Friday 19 January 2007 16:33, Wayne Topa wrote:
> 
> > They do here
> > alias deps='apt-cache showpkg $1'
> > alias policy="apt-cache policy $1"
> > alias 4page="a2ps --medium=Letter -4 $1"
> 
> If you're using bash, these may work in practice, but it isn't because of 
> the $1, which in the " case is being expanded when the alias is defined and 
> in the ' case is being expanded *after* the alias is evaluated, and will 
> always be undefined.
> 
> The reason it works at all is because when you alias something, the alias 
> part is expanded and the rest of the command is left in place. Remove those 
> $1's and you'll get the exact same effect.
> 

Well be dammed.  I 'learned' that when I first got into Linux back 14
years ago or so.  I would have sworn I read that in the Journal or a
man page or a book.  But you are correct.  

alias policy='apt-cache policy $1' or alias policy="apt-cache policy "
or alias policy='apt-cache policy ' all do work the same!

Never to old to learn I guess.

Now I have to go back and find just where I got that info to start
with!

Thanks Wesley, for the bash lesson!  :-)

Wayne

-- 
Hardware: The parts of a computer system that can be kicked.
_______________________________________________________



Reply to: