public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* using of getopts in bash
@ 2001-01-23  6:47 klaus.berndl
  2001-01-23  6:54 ` Christopher Faylor
  2001-01-23  7:00 ` Markus Hoenicka
  0 siblings, 2 replies; 4+ messages in thread
From: klaus.berndl @ 2001-01-23  6:47 UTC (permalink / raw)
  To: cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

Has anybody an easy understanding example for me how to use the bash build in command "getopts"
(or where i can find such an example)?? This would help me a lot...

Thank you in advance!
Klaus


-- 
Klaus Berndl			mailto: klaus.berndl@sdm.de
sd&m AG			http://www.sdm.de
software design & management	
Thomas-Dehler-Str. 27, 81737 München, Germany
Tel +49 89 63812-392, Fax -220


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: using of getopts in bash
  2001-01-23  6:47 using of getopts in bash klaus.berndl
@ 2001-01-23  6:54 ` Christopher Faylor
  2001-01-23  7:00 ` Markus Hoenicka
  1 sibling, 0 replies; 4+ messages in thread
From: Christopher Faylor @ 2001-01-23  6:54 UTC (permalink / raw)
  To: cygwin

On Tue, Jan 23, 2001 at 03:45:01PM +0100, klaus.berndl@sdm.de wrote:
>Has anybody an easy understanding example for me how to use the bash build in command "getopts"
>(or where i can find such an example)?? This would help me a lot...

getopts is built into bash.  It is not built into ash.
/bin/sh == ash.
/bin/bash != /bin/sh

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* using of getopts in bash
  2001-01-23  6:47 using of getopts in bash klaus.berndl
  2001-01-23  6:54 ` Christopher Faylor
@ 2001-01-23  7:00 ` Markus Hoenicka
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Hoenicka @ 2001-01-23  7:00 UTC (permalink / raw)
  To: cygwin

Some real-world example:

# read the command line options
while getopts ":d:hi:p:t:" opt; do
  case $opt in
    d  ) stylesheet=$OPTARG;;
    h  ) echo "creates formatted output from a DocBook SGML source"
	 echo 'usage: dbjade [-d style] [-h] [-i name] [-p prefix] [-t outformat] file1 [file2...]'
	 echo "Options: -d select stylesheet (d=default, m=m4, s=dbslide)"
	 echo "         -h print this help and exit"
	 echo "         -i set variable name in OpenJade"
	 echo "         -p use prefix for output filenames"
	 echo "         -t select the output format. Possible values are html,"
	 echo "            rtf, dvi, pdf, ps, tex, tps, tpdf. Default is tex."
	 exit 0 ;;
    i  ) includearg="-i "$OPTARG;;
    p  ) prefix=$OPTARG;;
    t  ) outformat=$OPTARG;;
    \? ) echo 'usage: dbjade [-d style] [-h] [-i name] [-p prefix] [-t outformat] file1 [file2...]'
	 echo 'type dbjade -h to invoke help'
	 exit 1;;
  esac
done

# correct the index so the filename argument is always $1
shift $(($OPTIND - 1))

klaus.berndl@sdm.de writes:
 > Has anybody an easy understanding example for me how to use the bash build in command "getopts"
 > (or where i can find such an example)?? This would help me a lot...
 > 

-- 
Markus Hoenicka, PhD
UT Houston Medical School
Dept. of Integrative Biology and Pharmacology
6431 Fannin MSB4.114
Houston, TX 77030
(713) 500-6313, -7477
(713) 500-7444 (fax)
Markus.Hoenicka@uth.tmc.edu
http://ourworld.compuserve.com/homepages/hoenicka_markus/


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: using of getopts in bash
  2001-01-23  6:59 AW: " klaus.berndl
@ 2001-01-23  7:04 ` Christopher Faylor
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Faylor @ 2001-01-23  7:04 UTC (permalink / raw)
  To: cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 862 bytes --]

On Tue, Jan 23, 2001 at 03:57:18PM +0100, klaus.berndl@sdm.de wrote:
>>>Has anybody an easy understanding example for me how to use the bash
>>>build in command "getopts" (or where i can find such an example)??
>>>This would help me a lot...
>>
>>getopts is built into bash.  It is not built into ash.
>>/bin/sh == ash.
>>/bin/bash != /bin/sh
>
>Thank you for this information (i know this already)...but how does
>this help me in using getopts in bash-scripts??? :-)
>Does this mean you recommend not to use getopts because it´s not built in
>in ash too?
>Anyway: I WANT to use getopts...

Good for you.  Sorry that I misinterpreted your email.

You are free to use it, of course.  I don't have any examples but the
"man bash" documentation seems pretty clear.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-01-23  7:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-23  6:47 using of getopts in bash klaus.berndl
2001-01-23  6:54 ` Christopher Faylor
2001-01-23  7:00 ` Markus Hoenicka
2001-01-23  6:59 AW: " klaus.berndl
2001-01-23  7:04 ` Christopher Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).