Can you access command line args from a source'd script?

Christopher R Volpe volpe at underdog.crd.ge.com
Sat Sep 15 01:12:07 AEST 1990


In article <1990Aug24.191615.27944 at usenet.ins.cwru.edu>,
boysko at dsrgsun.CES.CWRU.Edu (Glenn Boysko) writes:
|>Is it possible to get the filename of a sourced file (either Csh or Sh) while
|>the file is being sourced?
|>
|>For example, can you have a sourced file echo its pathname?  Something like:
|>
|>	% source <some_path_name>
|>
|>	I am <some_path_name>

Try the following: Create file "stest" containing the following:
  set line=`history 1`
  echo "My name is " $line[3]
  echo "My first arg is " $line[4]
  
%source stest arg1
My name is  stest
My first arg is  arg1
%

I'm sure you'll want to make it more robust, but that's the 
general idea.            
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.unix.questions mailing list