summaryrefslogtreecommitdiff
blob: 32affa18c1797e991b2dd3499466288481a1b1cf (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
http://lists.gnu.org/archive/html/bug-bash/2009-02/msg00158.html

make `return` accept negative values again

hack by me (vapier@gentoo.org) ... i'm not familiar with bash source code, so
i imagine this isn't the best way to do it ...

--- bash/builtins/return.def
+++ bash/builtins/return.def
@@ -60,9 +60,23 @@
 return_builtin (list)
      WORD_LIST *list;
 {
+	int neg = 0;
+	if (list && list->word && list->word->word) {
+		char *word = list->word->word;
+		if (*word == '-') {
+			while (*word++)
+				if (!isdigit(*word))
+					break;
+			if (!*word)
+				neg = 1;
+		}
+	}
+
+	if (!neg) {
   if (no_options (list))
     return (EX_USAGE);
   list = loptend;	/* skip over possible `--' */
+	}
 
   return_catch_value = get_exitstat (list);