Why is this not working?

From: Lekeas GK (cj571_at_soi.city.ac.uk)
Date: 05/26/04


Date: Wed, 26 May 2004 15:33:23 +0100

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).

Assuming I can get that to work, my next step would be to run which under
tcsh and return the result to standard input. How would that be possible?

I look forward to hearing from you soon.

Thanks in advance.

George



Relevant Pages

  • Re: Using alias within a bash script
    ... > script. ... > My particular command that i want to alias is echo. ... shopt -s expand_aliases ...
    (comp.unix.shell)
  • Re: Alias vs. script: test to use?
    ... >an alias for some command sequence? ... have to run the script via the "." ... A script can be run no matter what shell you're currently in. ...
    (comp.unix.shell)
  • Setting environment variables for tcsh session
    ... I'm trying to write a script I can run from tcsh in Terminal (on Mac ... This prints the command in the form I intended, ... the echo command printed the value of the variable I had ...
    (comp.lang.python)
  • Alias vs. script: test to use?
    ... Is there a good rule of thumb for deciding whether to use a script or ... an alias for some command sequence? ... A shell alias is really only good ... The two considerations I can think of are: ...
    (comp.unix.shell)
  • Re: Why preceed a "rm" command with a backslash?
    ... If the idea is to avoid using command line options, ... script doesn't get it. ... With a backslash, you escape any alias. ...
    (comp.unix.shell)