Path: utzoo!attcan!uunet!mcsun!ukc!keele!nott-cs!piaggio!anw From: anw@maths.nott.ac.uk (Dr A. N. Walker) Newsgroups: comp.unix.questions Subject: Re: Which script (was Re: comp.unix.questions) Message-ID: <1990Sep13.151130.10215@maths.nott.ac.uk> Date: 13 Sep 90 15:11:30 GMT References: <1990Sep7.152354.9439@ecn.purdue.edu> <563@DIALix.UUCP> Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker) Organization: Maths Dept., Nott'm Univ., UK. Lines: 24 In article <563@DIALix.UUCP> bernie@DIALix.oz.au (Bernd Felsche) writes: >In article <1990Sep7.152354.9439@ecn.purdue.edu> patkar@helium.ecn.purdue.edu (The Silent Dodo) writes: >>[...] How can a shell script >>(sh or csh) find out [the directory of] its own file name? > [gives shell script to parse the PATH] Just to point out that any such script is easily spoofed, in case this is a security- or accounting-related problem. Try something like $ PATH=/something/innocuous export PATH $ /bin/sh $ PATH=/secret/directory # note, no export $ spoof and "spoof" will look for itself in "/something/innocuous", even though it was found in "/secret/directory". At least, it does in SunOS 4.0.3, and it does with our somewhat modded SysV shell, though I don't remember seeing anywhere a definition of what *should* happen if an exported variable is masked by an unexported one. -- Andy Walker, Maths Dept., Nott'm Univ., UK. anw@maths.nott.ac.uk