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

Barry Margolin barmar at think.com
Sat Sep 15 10:03:28 AEST 1990


In article <11888 at crdgw1.crd.ge.com> volpe at underdog.crd.ge.com (Christopher R Volpe) writes:
>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?
>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]

This will only work for scripts sourced interactively.  If stest is sourced
from another sourced script then it will show the outer script name.  And
if it is sourced from a script executed in a subshell then there won't be
any history maintained for that shell.
--
Barry Margolin, Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.unix.questions mailing list