* getopts does not work in a shell script
@ 1998-08-27 4:00 Regionalfernsehen Kuessnacht
1998-08-27 4:00 ` Bob Harris
1998-08-27 4:00 ` Wolfram Klaus
0 siblings, 2 replies; 3+ messages in thread
From: Regionalfernsehen Kuessnacht @ 1998-08-27 4:00 UTC (permalink / raw)
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.
Tom
__________________________________________________________
To avoid spam I replaced my email addres.
Replace 'nospam' with 'ife.ee' to send me a mail
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: getopts does not work in a shell script
1998-08-27 4:00 getopts does not work in a shell script Regionalfernsehen Kuessnacht
1998-08-27 4:00 ` Bob Harris
@ 1998-08-27 4:00 ` Wolfram Klaus
1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Klaus @ 1998-08-27 4:00 UTC (permalink / raw)
Regionalfernsehen Kuessnacht <rfk@geocities.com> 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 |
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: getopts does not work in a shell script
1998-08-27 4:00 getopts does not work in a shell script Regionalfernsehen Kuessnacht
@ 1998-08-27 4:00 ` Bob Harris
1998-08-27 4:00 ` Wolfram Klaus
1 sibling, 0 replies; 3+ messages in thread
From: Bob Harris @ 1998-08-27 4:00 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-08-27 4:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-08-27 4:00 getopts does not work in a shell script Regionalfernsehen Kuessnacht
1998-08-27 4:00 ` Bob Harris
1998-08-27 4:00 ` Wolfram Klaus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox