From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10fdc2,924afd4c13d07312 X-Google-Attributes: gid10fdc2,public X-Google-Thread: fee84,924afd4c13d07312 X-Google-Attributes: gidfee84,public X-Google-Thread: 1012a6,924afd4c13d07312 X-Google-Attributes: gid1012a6,public From: Bob Vickers Subject: Re: Sh shell script problem on OSF4.0 (but not on SGI) (getopts and shift) Date: 1997/05/28 Message-ID: <338BF0E4.41C6@dcs.rhbnc.ac.uk>#1/1 X-Deja-AN: 244397151 References: <33831D34.41C6@toonboom.com> To: Maximillien Lincourt Organization: Royal Holloway College, University of London Newsgroups: comp.unix.osf.osf1,comp.unix.shell,comp.sys.sgi.bugs Maximillien Lincourt wrote: > > I'm trying to use the getopts argument parser in a sh shell script, on > DEC's OSF1 (4.0 and on SGI 6.x) but I seem to be having some soft of > problems using it. It seems that the getopts does not get called! is the > man page wrong or there's something I don't understand, could it be that > getopts path is wrong ? > > There's also a problem with the shift command, is the syntax correct > with all the parentheses on the sh man page on SGI they use > > shift `expr $OPTIND - 1` > As far as I can make out, /bin/getopts is a total waste of space, written by someone who doesn't know the first law of Unix programming: "A Unix process cannot alter the environment of its parent". getopts has to be a shell built-in command, otherwise it won't work. ksh has it, bash has it and many implementations of sh have it. Change the first line of your script to #!/bin/ksh and you should begin to get consistent behaviour between SGI and DEC. Any comments from DEC about this? Bob -- ====================================================================== Bob Vickers R.Vickers@rhbnc.ac.uk Dept of Computer Science, Royal Holloway College, University of London WWW: http://www.dcs.rhbnc.ac.uk/%7Ebobv/ Phone: +44 1784 443691