getopt example in docs incorrectly implies /bin/sh may not be used (PATCH)

Bug #1319655 reported by jimav
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
util-linux (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

getopt(1) works with /bin/sh, bash, and probably other Bourne-ish shells (as well as csh-family shells with the appropriate option).

However the included examples give the impression that something about getopt(1) makes it incompatible with /bin/sh, leading one to assume that scripts MUST use bash instead of sh. The author probably meant merely that the "bash" example would not work with tcsh; however less-experienced script writers might not find that to be obvious.

First of all, the Bourne-syntax example unnecessarily uses bash, i.e. leading one to wonder why the more-universal sh shell could not be used. And there is a comment in the example saying "This program will only work with bash(1)".

SUGGESTED IMPROVEMENT (patch attached):

. Rename /usr/share/doc/util-linux/examples/getopt-parse.bash to getopt-parse.sh

. Change the example to use /bin/sh instead of bash, and change the comment to say that that example works only with sh-compatible shells, including bash.

P.S. The --shell option to getopt(1) accepts arguments 'sh', 'bash', 'csh', and 'tcsh', however internally there is no difference between 'sh' and 'bash' (or between 'csh' and 'tcsh'). See source code at https://kernel.googlesource.com/pub/scm/utils/util-linux/util-linux/+/v2.22.2/misc-utils/getopt.c

ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: util-linux 2.20.1-5.1ubuntu9
ProcVersionSignature: Ubuntu 3.11.0-20.34-generic 3.11.10.6
Uname: Linux 3.11.0-20-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.12.5-0ubuntu2.2
Architecture: amd64
Date: Wed May 14 21:00:48 2014
InstallationDate: Installed on 2013-08-06 (282 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Release amd64 (20130424)
MarkForUpload: True
SourcePackage: util-linux
UpgradeStatus: Upgraded to saucy on 2013-10-24 (202 days ago)

Revision history for this message
jimav (james-avera) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in util-linux (Ubuntu):
status: New → Confirmed
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "patch.txt" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in util-linux (Ubuntu):
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.