Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: harris@zk3.dec.com (Bob Harris)
Subject: Re: getopts does not work in a shell script
Date: 1998/08/27	[thread overview]
Message-ID: <harris-ya023680002708980828030001@usenet.pa.dec.com> (raw)
In-Reply-To: 35E51F9E.80F9DD04@nospam.ethz.ch

In article <35E51F9E.80F9DD04@nospam.ethz.ch>, Regionalfernsehen Kuessnacht
<rfk@geocities.com> 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.



      parent reply	other threads:[~1998-08-27  4:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-27  4:00 getopts does not work in a shell script Regionalfernsehen Kuessnacht
1998-08-27  4:00 ` Wolfram Klaus
1998-08-27  4:00 ` Bob Harris [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox