]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
getopt: clarify the use of '--long' instead of '--longoptions' in shell examples
authorcgoesche <cgoesc2@wgu.edu>
Sat, 23 Aug 2025 01:52:29 +0000 (21:52 -0400)
committercgoesche <cgoesc2@wgu.edu>
Sat, 23 Aug 2025 01:52:29 +0000 (21:52 -0400)
Addresses: #2593
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
misc-utils/getopt-example.bash
misc-utils/getopt-example.tcsh

index 0870882af02a7216ed0c1ee9b6771da40c871bae..78757ef6852cf610294f422ac014956da88c4b9c 100644 (file)
@@ -20,6 +20,9 @@
 # Note that we use "$@" to let each command-line parameter expand to a
 # separate word. The quotes around "$@" are essential!
 # We need TEMP as the 'eval set --' would nuke the return value of getopt.
+#
+# Note: We can use '--long' instead of '--longoptions', because getopt(3) 
+# allows unique abbreviations of long option names.
 TEMP=$(getopt -o 'ab:c::' --long 'a-long,b-long:,c-long::' -n 'example.bash' -- "$@")
 
 if [ $? -ne 0 ]; then
index 2b822943fdc1de04bef219c2c4d8b42a932f63a0..094efa46fe163cb94961de501c62efcfe1d48d3d 100644 (file)
@@ -26,6 +26,9 @@
 # as a list. The ':q`  copies that list without doing any substitutions:
 # each element of argv becomes a separate argument for getopt. The braces
 # are needed because the result is also a list.
+#
+# Note: We can use '--long' instead of '--longoptions', because getopt(3) 
+# allows unique abbreviations of long option names.
 set temp=(`getopt -s tcsh -o ab:c:: --long a-long,b-long:,c-long:: -- $argv:q`)
 if ($? != 0) then
   echo "Terminating..." >/dev/stderr