Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.unix.questions Subject: Re: Can you access command line args from a source'd script? Keywords: source, . Message-ID: <1990Sep15.000328.13581@Think.COM> Date: 15 Sep 90 00:03:28 GMT References: <1990Aug24.191615.27944@usenet.ins.cwru.edu> <11888@crdgw1.crd.ge.com> Sender: news@Think.COM Distribution: na Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 19 In article <11888@crdgw1.crd.ge.com> volpe@underdog.crd.ge.com (Christopher R Volpe) writes: >In article <1990Aug24.191615.27944@usenet.ins.cwru.edu>, >boysko@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@think.com {uunet,harvard}!think!barmar