summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorEric Andersen2000-08-21 22:02:34 +0000
committerEric Andersen2000-08-21 22:02:34 +0000
commita1f16bba72c78eca9359692e354fa35c0f3366c1 (patch)
treef95f7cd59b05597b5719ae6f50ea81b62b70294a /docs
parente2205f093bbdd251de8b2efe1f63925510fcbad5 (diff)
downloadbusybox-a1f16bba72c78eca9359692e354fa35c0f3366c1.zip
busybox-a1f16bba72c78eca9359692e354fa35c0f3366c1.tar.gz
Added getopt(1) from "Alfred M. Szmidt" <ams@trillian.itslinux.org>
-Erik
Diffstat (limited to 'docs')
-rw-r--r--docs/busybox.pod46
-rw-r--r--docs/busybox.sgml55
2 files changed, 99 insertions, 2 deletions
diff --git a/docs/busybox.pod b/docs/busybox.pod
index 916ccb6..4fba7ea 100644
--- a/docs/busybox.pod
+++ b/docs/busybox.pod
@@ -57,7 +57,7 @@ Currently defined functions include:
ar, basename, cat, chgrp, chmod, chown, chroot, chvt, clear, cp, cut, date,
dc, dd, deallocvt, df, dirname, dmesg, du, dumpkmap, dutmp, echo, false, fbset,
-fdflush, find, free, freeramdisk, fsck.minix, grep, gunzip, gzip, halt,
+fdflush, find, free, freeramdisk, fsck.minix, getopt, grep, gunzip, gzip, halt,
head, hostid, hostname, id, init, insmod, kill, killall, length, ln,
loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, mkdir,
mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc,
@@ -614,6 +614,48 @@ Options:
-------------------------------
+=item getopt
+
+Usage: getopt [OPTIONS]...
+
+Parse command options
+
+Options:
+
+ -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"
+
+Example:
+ $ 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
+
+
+-------------------------------
+
=item grep
Usage: grep [OPTIONS]... PATTERN [FILE]...
@@ -2052,4 +2094,4 @@ Enrique Zanardi <ezanardi@ull.es>
=cut
-# $Id: busybox.pod,v 1.61 2000/08/21 21:18:52 andersen Exp $
+# $Id: busybox.pod,v 1.62 2000/08/21 22:02:34 andersen Exp $
diff --git a/docs/busybox.sgml b/docs/busybox.sgml
index 864dbe0..f53be8d 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>