From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,5b69affb39c28736 X-Google-Attributes: gidfee84,public From: klaus@axp4.physik.fu-berlin.de (Wolfram Klaus) Subject: Re: getopts does not work in a shell script Date: 1998/08/27 Message-ID: #1/1 X-Deja-AN: 385260803 Content-Transfer-Encoding: 8bit References: <35E51F9E.80F9DD04@nospam.ethz.ch> X-Trace: fu-berlin.de 904222942 2488 (none) 160.45.32.195 Organization: Freie Universitaet Berlin X-Access: 16 17 19 Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 Regionalfernsehen Kuessnacht writes: >Hi >I tried to use the getopts command to process options in a shell script, >without success. The options processing works as follows: >#!/bin/sh >while getopts fdi opt >do > case $opt in > 'f') echo full ;; > 'd') echo differential ;; > 'i') echo incremental ;; > '?') echo options: [-fdi] > exit 2 ;; > esac >done >I tried the same script also on a sun with unix. It works correctly >there, >but not on the DEC. Please help. >Thank you. I just played around a little and found out that the example at the end of the man-page of getopts works if you either use #!/bin/ksh or set the environmet variable BIN_SH to xpg4 and use #!/bin/sh thus getting the POSIX.2 version of the shell instead of the historical SVR4 version. Maybe this helps you, Wolfram > Tom >__________________________________________________________ >To avoid spam I replaced my email addres. >Replace 'nospam' with 'ife.ee' to send me a mail -- """ (o o) +---------------------------------oOO--(_)--OOo-------------------------------+ | Wolfram Klaus (klaus@physik.fu-berlin.de) FU Berlin, FB Physik |