Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!mintaka!spdcc!tauxersvilli!alphalpha!nazgul From: nazgul@alphalpha.com (Kee Hinckley) Newsgroups: comp.sys.apollo Subject: Re: AEGIS Shell argument processing... Message-ID: <1991Jun15.195658.29100@alphalpha.com> Date: 15 Jun 91 19:56:58 GMT References: <9106131931.AA08669@cel.cummins.com> Organization: asi Lines: 56 In article <9106131931.AA08669@cel.cummins.com> philip@cel.cummins.com (Philip D. Pokorny) writes: >#!/com/sh ># Print shell arguments. >eon > >n := 0 > >while(( ^"set -c args @^^n" <> "" )) do > arg := ^"set -c args @^^n" > args (( "Argument " + ^n + ": " + ^arg )) > n := ^n + 1 >enddo Or... #!/com/sh eon # # Note that this will exit the loop early if there are any 0 length arguments. # for i := 1 to 99999 arg := ^"set -c args ^^i" if eqs ^arg '' then exit endif # Do your stuff here. args ^arg endfor # Btw. Here's the explanation, from the inside out. # args ^^i -> ^1 # set -c args ^1 -> # # set -c is like saying 'sh -c' except that it's faster and takes place at the # current level. This would have worked with "sh -c" as well. We are taking # advantage of the fact that command line arguments after -c are reparsed, so # we get one extra level of parsing. # # I *wrote* the shell and it it took me over a year to figure this hack out. # There really needs to be a better mechanism. Hopefully it will come out in # some future release. Note. If you KNOW that none of your arguments have any # spaces in them you can make this process much simpler by just saying: # # for arg in ^* # ... # endfor # -- Alfalfa Software, Inc. | Poste: The EMail for Unix nazgul@alfalfa.com | Send Anything... Anywhere 617/646-7703 (voice/fax) | info@alfalfa.com I'm not sure which upsets me more: that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's.