[comp.unix.internals] Alias to change path on the fly

paquette@cs-sun-fsa.cpsc.ucalgary.ca (Trevor Paquette) (11/08/90)

 Quick and I hope a fairly simple question. We have some programs
that must be able to take advantage of two co-processors on a sun.
The executables are name prog_host (no coprocessor), prog_sc (Supercard
coprocessor) and prog_qc (Quickcard coprocessor).
 Each executable is in a seperate directory. I want to be able to change
my path on the fly to get at a certain executable. This is what I have
done so far.
Let's say my path is set as :
(. /usr/ucb /bin /usr/bin /usr/local/bin /home/insight/sparc/bin/itahost)
                                                                 *******
itahost contains all the prog_host executables.
itaqc   contains all the prog_qc executables.
itasc   contains all the prog_sc executables.

I have come up with the following aliases to change which directory I will use

alias host 'echo set path=\($path\)|sed s/itaqc/itahost/|sed s/itasc/itahost/'
alias qc   'echo set path=\($path\)|sed s/itahost/itaqc/|sed s/itasc/itaqc/  '
alias sc   'echo set path=\($path\)|sed s/itaqc/itasc/  |sed s/itahost/itasc/'

 These aliases of course only ECHO what the command to change the path should 
be.
To actually execute the command we must put some ` around the command.

 So the new aliases should be:
alias host '`echo set path=\($path\)|sed s/itaqc/itahost/|sed s/itasc/itahost/`'
alias qc   '`echo set path=\($path\)|sed s/itahost/itaqc/|sed s/itasc/itaqc/  `'
alias sc   '`echo set path=\($path\)|sed s/itaqc/itasc/  |sed s/itahost/itasc/`'
  But these new aliases give me the following error: 

`echo set path=\($path\)|sed s/itaqc/itahost/|sed s/itasc/itahost/`: Ambiguous

 What am I doing wrong???????????

  Trev
-- 
______________________________________/Through the darkness, the future past,
Trevor Paquette  ICBM:51'03"N/114'05"W|The magician longs to see.
{ubc-cs,utai,alberta}!calgary!paquette|One chants out, between two worlds,
paquette@cpsc.ucalgary.ca             |"Fire, walk with me."

jpe@egr.duke.edu (John P. Eisenmenger) (11/09/90)

From article <1990Nov8.014515.13882@cpsc.ucalgary.ca>, by paquette@cs-sun-fsa.cpsc.ucalgary.ca (Trevor Paquette):
>  So the new aliases should be:
> alias host '`echo set path=\($path\)|sed s/itaqc/itahost/|sed s/itasc/itahost/`'
> alias qc   '`echo set path=\($path\)|sed s/itahost/itaqc/|sed s/itasc/itaqc/  `'
> alias sc   '`echo set path=\($path\)|sed s/itaqc/itasc/  |sed s/itahost/itasc/`'
>   But these new aliases give me the following error: 
> 
> `echo set path=\($path\)|sed s/itaqc/itahost/|sed s/itasc/itahost/`: Ambiguous
> 
>  What am I doing wrong???????????

try these:

alias host 'set path = ( `echo $path | sed -e s/itaqc/itahost/ -e s/itasc/itahost/` )
alias qc   'set path = ( `echo $path | sed -e s/itahost/itaqc/ -e s/itasc/itaqc/`   )
alias sc   'set path = ( `echo $path | sed -e s/itahost/itasc/ -e s/itaqc/itasc/`   )

-John

tif@doorstop.austin.ibm.com (Paul Chamberlain) (11/10/90)

In article <1990Nov8.014515.13882@cpsc.ucalgary.ca> paquette@cs-sun-fsa.cpsc.ucalgary.ca (Trevor Paquette) writes:
>I have come up with the following aliases to change which directory I will use
>...
>alias host '`echo set path=\($path\)|sed s/itaqc/itahost/|sed s/itasc/itahost/`'
>...

Untested but much more likely to succeed alias follows:

alias host 'set path=(`echo $path|sed s/itaqc/itahost/|sed s/itasc/itahost/`)'
...

But, if I were you, I'd do something like this (which I even tested):

alias host 'set path=(`echo $path|sed "s/ita[a-z]*/itahost/"`)'

Paul Chamberlain | I do NOT represent IBM.     tif@doorstop, sc30661 at ausvm6
512/838-7008     | ...!cs.utexas.edu!ibmchs!auschs!doorstop.austin.ibm.com!tif