View Single Post

   
  #4 (permalink)  
Old 01-16-2008, 05:21 PM
Jan Gerrit Kootstra
 
Posts: n/a
Default Re: alias substitution fails

"J" <snakes_boi@yahoo.co.uk> schreef in bericht
news:1068210975.734412@ernani.logica.co.uk...
> Thanks,
>
> This works fine now - I'd forgotten that the shell did things in a certain
> order.....
>
> Cheers,
>
> Jon
> "Siem Korteweg" <NOsiemkSPAM@open-challenge.nl> wrote in message
> news:3fab6e15$0$58714$e4fe514c@news.xs4all.nl...
> >
> > "J" <snakes_boi@yahoo.co.uk> wrote in message
> > news:1068195165.588181@ernani.logica.co.uk...
> > > Hello All,
> > > Can anyone advise me regarding the following problem/bug?
> > > I have used an example below...
> > >
> > > On the command line......I set up the following...
> > >
> > > $alias test='/usr/bin/ls'
> > > $
> > > $ export LIST="test /home/myhome"

> > ...
> > > $ $LIST
> > > + test /home/myhome
> > > $
> > >
> > > Why in the second case even though the variable $LIST is expanded out

> does
> > > the shell not realise that 'test' is an alias? Is this a bug?

Everything
> > is
> > > still set okay but it doesn't substitute 'test'.

> >
> > The shell is an interpreter that reads each line and pre-processes it

> before
> > executing it. The preprocessing is done in the following order:
> > - alias substitution
> > - variable substitution
> > - ....
> > The shell reads "$LIST" and cannot find an alias. It then finds a

variable
> > with that name and substitutes "test". However, it does not go back to

the
> > first stage to check whether an alias has been used. To let the shell
> > retrace it's steps you can use the eval command.
> >
> > eval $LIST
> >
> > will give you the result you wanted.
> >
> > Siem Korteweg
> > __________________________________________________ _______
> > Siem Korteweg
> > Open Challenge www.open-challenge.nl/scc/index.html
> > Havenweg 24A telefoon: 0347 324 130
> > 4131 NM Vianen fax : 0347 324 120
> > __________________________________________________ _______
> >
> >

>
>


Jon,


Be carefull with using the name test for aliases, shell-scripts or
programms.

Do you realise what you do by using test?

You overwrite the test command that is used in a lot of if statement of
shell scripts.

So some shell scripts may not work, if your alias would be put in a .profile
of a user or /etc/profile.


Regards,


Jan Gerrit


Reply With Quote