Re: Why is this not working?

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 05/28/04

  • Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: Why is this not working?"
    Date: Thu, 27 May 2004 18:13:20 -0400
    
    

    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.

    -- 
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    

  • Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: Why is this not working?"

    Relevant Pages

    • Re: Why is this not working?
      ... >> What do you mean aliases are not exported? ... > is executing the script. ...
      (comp.unix.questions)
    • Re: [opensuse] alias failure
      ... So it's just an accident that the following aliases all work as I ... It's uncommon for interactive shells to have any positional parameters ... Unlike the very limited capabilities of aliases, shell procedures ... I made a script with nothing but that in it, ...
      (SuSE)
    • Re: [PS] - Help with becoming better
      ... If I give it ps for input, then I get back Get-Process which is of course ... I think this does pretty much the same as your script. ... I write an actual script however, I would rather avoid the use of aliases as ...
      (microsoft.public.windows.server.scripting)
    • Re: [PS] - Help with becoming better
      ... I didn't take it to handling parameters, ... I think this does pretty much the same as your script. ... I write an actual script however, I would rather avoid the use of aliases as ...
      (microsoft.public.windows.server.scripting)
    • Re: [PS] - Help with becoming better
      ... If I give it ps for input, then I get back Get-Process which is of course ... I think this does pretty much the same as your script. ... I write an actual script however, I would rather avoid the use of aliases as ...
      (microsoft.public.windows.server.scripting)