Re: Why is this not working?
Jens.Toerring_at_physik.fu-berlin.de
Date: 05/28/04
- Previous message: Barry Margolin: "Re: Why is this not working?"
- In reply to: Barry Margolin: "Re: Why is this not working?"
- Next in thread: Lekeas GK: "Re: Why is this not working?"
- Reply: Lekeas GK: "Re: Why is this not working?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 May 2004 22:35:50 GMT
Barry Margolin <barmar@alum.mit.edu> wrote:
> In article <Pine.GSO.4.58.0405272058001.9008@vega.soi.city.ac.uk>,
> Lekeas GK <cj571@soi.city.ac.uk> wrote:
>> >> Hi All,
>> >>
>> >> I am trying to create a script which would look like the which command
>> >> under tcsh. I wrote the following script:
>> >>
>> >> #! /usr/bin/bash
>> >> if ! `alias $1`; then
>> >> echo "$1 is aliased to " `alias $1|cut -d\' -f2`
>> >> fi
>> >>
>> >> However, when I execute it I get touch is aliased to ( which is not
>> >> true, as I have created an alias for touch).
>> >
>> > Aliases are not exported.
>>
>> What do you mean aliases are not exported? From where to where? I only
>> want alias $1|cut -d\' -f2 to run - as it is within backquotes - and
>> produce /usr/bin/touch. However, it is not producing anything and I am
>> very curious why this is happening.
> Aliases are not exported from your login shell to the shell process that
> is executing the script. ~/.bashrc is only executed by default in
> interactive shell processes, and the script is being run by a
> non-interactive shell.
So you might use
#! /usr/bin/bash -l
if [ -n "`alias $1 2>/dev/null`" ]; then
echo "$1 is aliased to " `alias $1 | cut -d\' -f2`
fi
Regards, Jens
-- \ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de \__________________________ http://www.toerring.de
- Previous message: Barry Margolin: "Re: Why is this not working?"
- In reply to: Barry Margolin: "Re: Why is this not working?"
- Next in thread: Lekeas GK: "Re: Why is this not working?"
- Reply: Lekeas GK: "Re: Why is this not working?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|