You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-shells/bash/files/bash-4.0-negative-return.patch

34 lines
748 B

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);