diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-08-21 22:02:34 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-08-21 22:02:34 +0000 |
commit | a1f16bba72c78eca9359692e354fa35c0f3366c1 (patch) | |
tree | f95f7cd59b05597b5719ae6f50ea81b62b70294a /docs/busybox.sgml | |
parent | e2205f093bbdd251de8b2efe1f63925510fcbad5 (diff) |
Added getopt(1) from "Alfred M. Szmidt" <ams@trillian.itslinux.org>
-Erik
Diffstat (limited to 'docs/busybox.sgml')
-rw-r--r-- | docs/busybox.sgml | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/docs/busybox.sgml b/docs/busybox.sgml index 864dbe0ac..f53be8d6f 100644 --- a/docs/busybox.sgml +++ b/docs/busybox.sgml @@ -1063,6 +1063,61 @@ </screen> </para> </sect1> + + <sect1 id="getopt"> + <title>getopt</title> + + <para> + Usage: getopt [OPTIONS]... + </para> + + <para> + Parse command options + </para> + + <para> + <screen> + -a, --alternative Allow long options starting with single -\n" + -l, --longoptions=longopts Long options to be recognized\n" + -n, --name=progname The name under which errors are reported\n" + -o, --options=optstring Short options to be recognized\n" + -q, --quiet Disable error reporting by getopt(3)\n" + -Q, --quiet-output No normal output\n" + -s, --shell=shell Set shell quoting conventions\n" + -T, --test Test for getopt(1) version\n" + -u, --unqote Do not quote the output\n" + </screen> + </para> + + + <para> + Example: + </para> + + <para> + <screen> + $ cat getopt.test + #!/bin/sh + GETOPT=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \ + -n 'example.busybox' -- "$@"` + if [ $? != 0 ] ; then exit 1 ; fi + eval set -- "$GETOPT" + while true ; do + case $1 in + -a|--a-long) echo "Option a" ; shift ;; + -b|--b-long) echo "Option b, argument \`$2'" ; shift 2 ;; + -c|--c-long) + case "$2" in + "") echo "Option c, no argument"; shift 2 ;; + *) echo "Option c, argument \`$2'" ; shift 2 ;; + esac ;; + --) shift ; break ;; + *) echo "Internal error!" ; exit 1 ;; + esac + done + </screen> + </para> + </sect1> <sect1 id="grep"> <title>grep</title> |