Your message dated Wed, 27 Jun 2012 11:15:16 +0000 (UTC) with message-id <Pine.BSM.4.64L.1206271113520.3110@herc.mirbsd.org> and subject line pdksh: bizarre behavior of getopt in shell functions has caused the Debian Bug report #47848, regarding pdksh: bizarre behavior of getopt in shell functions to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@bugs.debian.org immediately.) -- 47848: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=47848 Debian Bug Tracking System Contact owner@bugs.debian.org with problems
--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: pdksh: bizarre behavior of getopt in shell functions
- From: Zack Weinberg <zack@bitmover.com>
- Date: Tue, 19 Oct 1999 21:28:27 -0700
- Message-id: <199910200428.VAA03104@zack.bitmover.com>
Package: pdksh Version: 5.2.14-1 Severity: normal Consider this shell script. -- fun_a () { while getopts ksgq opt do echo $opt done } fun_b () { while getopts a: opt do echo $opt $OPTARG done shift `expr $OPTIND - 1` echo "$@" fun_a -k -sg } fun_b echo fun_b -a blah echo fun_b -a blah bar -- I expected it to print this: $ att-ksh test.sh k s g a blah k s g a blah bar k s g $ but it actually does this: $ pdksh test.sh k s g a blah bar $ Please fix. zw -- System Information Debian Release: potato Kernel Version: Linux zack 2.2.13pre15 #1 Mon Oct 4 22:12:49 PDT 1999 i686 unknown Versions of the packages pdksh depends on: ii libc6 2.1.2-5 GNU C Library: Shared libraries and timezone
--- End Message ---
--- Begin Message ---
- To: 47848-done@bugs.debian.org
- Subject: pdksh: bizarre behavior of getopt in shell functions
- From: Thorsten Glaser <tg@mirbsd.de>
- Date: Wed, 27 Jun 2012 11:15:16 +0000 (UTC)
- Message-id: <Pine.BSM.4.64L.1206271113520.3110@herc.mirbsd.org>
Hi, this is not a bug, cf. man mksh: Functions defined with the function reserved word are treated differently in the following ways from functions defined with the () notation: […] · OPTIND is saved/reset and restored on entry and exit from the func- tion so getopts can be used properly both inside and outside the function (Bourne-style functions leave OPTIND untouched, so using getopts inside a function interferes with using getopts outside the function). Changing your script to read “function fun_a {” (and fun_b) makes it behave as you expect. bye, //mirabilos -- 13:37⎜«Natureshadow» Deep inside, I hate mirabilos. I mean, he's a good guy. But he's always right! In every fsckin' situation, he's right. Even with his deeply perverted taste in software and borked ambition towards broken OSes - in the end, he's damn right about it :(! […] works in mksh
--- End Message ---