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: harris@zk3.dec.com (Bob Harris) Subject: Re: getopts does not work in a shell script Date: 1998/08/27 Message-ID: #1/1 X-Deja-AN: 385265723 Content-Transfer-Encoding: 8bit References: <35E51F9E.80F9DD04@nospam.ethz.ch> Content-Type: text/plain; charset=ISO-8859-1 Organization: Digital Equipment Corporation Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 In article <35E51F9E.80F9DD04@nospam.ethz.ch>, Regionalfernsehen Kuessnacht wrote: >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. There are 2 'sh' shells on Digital UNIX. The default is the bourne shell (/usr/bin/sh) which does not support getopts. The other 'sh' is the POSIX and XPG4 compliant shell (/usr/bin/posix/sh) which _DOES_ support getopts. The sh man page tells you about both shells as well as how to set up environment variables that will control which shell is spawned. The 'man 1p sh' gives details about the XPG4 and POSIX shell and 'man 1b sh' gives details about the bourne shell. -- Bob Harris "I don't get to tell me what to do, I only get to tell me how to do it." Comments expressed here are my own and _NOT_ those of my employer.