Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!bionet!ames!dftsrv!nssdcs!setzer From: setzer@nssdcs (William Setzer (IDM)) Newsgroups: comp.unix.questions Subject: Recursive shell scripts Message-ID: <343@dftsrv.gsfc.nasa.gov> Date: 30 Jun 89 18:16:12 GMT Sender: news@dftsrv.gsfc.nasa.gov Reply-To: setzer@nssdcs (William Setzer (IDM)) Distribution: usa Organization: NSSDC Greenbelt Md. Lines: 29 I am trying to use the Bourne shell to write recursive shell scripts. The problem is that I can't get the positional parameters to pass correctly. Here is what I've written. -------------- #!/bin/sh export PATH cd ${1:-`pwd`} for I in `ls` do if test -d $I; then . $0 $I; else echo `pwd`'/'$I fi done ------------- According to what the man page says, this should work, but it doesn't. For some reason or another, the $I parameter isn't being passed back into the program (I always get the same value for $1). I know they can be passed; I wrote a script that did it. My best guess is that somehow it finds itself linked in memory and decided to link to the already running process. I tried putting parens around '. $0 $I' to run it in it's own subshell, but that didn't work either. I'm stumped. Can anyone help me? Thanx. Oh yeah, I'm running SunOS 4.0 (it's really BSD 4.?). William Setzer setzer@nssdcs.gsfc.nasa.gov