slackbuilds_ponce/system/pdksh/patches/110_Debian-exit-negative-number.patch

47 lines
1.3 KiB
Diff
Raw Normal View History

2010-05-13 01:01:03 +02:00
Fix problem with `exit -1' giving `ksh: exit: -1: unknown option' (see bug#502934)
Index: pdksh-5.2.14/c_sh.c
===================================================================
--- pdksh-5.2.14.orig/c_sh.c 2009-09-19 11:38:39.000000000 +0200
+++ pdksh-5.2.14/c_sh.c 2009-09-19 11:39:33.000000000 +0200
@@ -534,9 +534,14 @@
int n;
char *arg;
- if (ksh_getopt(wp, &builtin_opt, null) == '?')
- return 1;
- arg = wp[builtin_opt.optind];
+ if (!Flag(FPOSIX) // not posix
+ && *wp && *(wp + 1) && !*(wp + 2)) // only one argument passed
+ arg=*(wp + 1); // code regardless of starting with '-' or not
+ else {
+ if (ksh_getopt(wp, &builtin_opt, null) == '?')
+ return 1;
+ arg = wp[builtin_opt.optind];
+ }
if (arg) {
if (!getn(arg, &n)) {
Index: pdksh-5.2.14/tests/debian-110.t
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ pdksh-5.2.14/tests/debian-110.t 2009-09-19 11:41:59.000000000 +0200
@@ -0,0 +1,17 @@
+name: debian-110-1
+description:
+ Check if exit -1 is allowed for ! posix
+stdin:
+ (set +o posix; exit -1); echo A $?
+expected-stdout:
+ A 255
+---
+name: debian-110-2
+description:
+ Check if exit -1 is not allowed for posix
+stdin:
+ (set -o posix; exit -1); echo A $?
+expected-stdout:
+ A 1
+expected-fail: yes
+---