Xref: utzoo comp.unix.shell:848 comp.unix.programmer:459 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!crdgw1!uunet!ibmps2!aix!vendijb From: vendijb@aix.aix.kingston.ibm.com (JB Christy) Newsgroups: comp.unix.shell,comp.unix.programmer Subject: Re: Alias to change path on the fly Message-ID: <4431@aix.aix.kingston.ibm.com> Date: 8 Nov 90 15:58:33 GMT References: <1990Nov8.014515.13882@cpsc.ucalgary.ca> Followup-To: comp.unix.shell Organization: Resource One, Inc. Lines: 35 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/' }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 csh parses commands before it does variable and command substitutions, so by the time it's figured out the output of your echo, it's no longer looking for a command. You have two choices. You can explicitly tell csh to parse the command after substitution (i.e. to 'eval'uate the output of your echo -- see the csh man page under the 'eval' command): alias sc 'eval `echo set path=\($path\)|sed s/itaqc/itasc/ |sed s/itahost/itasc/`' Or, more directly, you can just set the path to the proper thing yourself: alias sc 'set path=`echo \($path\)|sed s/itaqc/itasc/ |sed s/itahost/itasc/`' -- JB (Beth) Christy "She was a suicide blonde -- Resource One, Inc. dyed by her own hand." *** I speak only for myself, and half the time I get that wrong. ***