blob: d7af113275f30b47799839b88fcb021335fdd2ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
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
+---
|