diff options
author | jilles <jilles@FreeBSD.org> | 2011-06-12 23:06:04 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-06-12 23:06:04 +0000 |
commit | 91789615b49a87147298eee12c9b111d8c1b64c9 (patch) | |
tree | b1cbd950b159dbb3fa6211ba5a7f7fb7709a612e /bin/sh/jobs.c | |
parent | 5f2600c6a978923a3904716ce73814baca63fd0f (diff) | |
download | FreeBSD-src-91789615b49a87147298eee12c9b111d8c1b64c9.zip FreeBSD-src-91789615b49a87147298eee12c9b111d8c1b64c9.tar.gz |
sh: Save/restore changed variables in optimized command substitution.
In optimized command substitution, save and restore any variables changed by
expansions (${var=value} and $((var=assigned))), instead of trying to
determine if an expansion may cause such changes.
If $! is referenced in optimized command substitution, do not cause jobs to
be remembered longer.
This fixes $(jobs $!) again, simplifies the man page and shortens the code.
Diffstat (limited to 'bin/sh/jobs.c')
-rw-r--r-- | bin/sh/jobs.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 434af22..cbc29f1 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include "memalloc.h" #include "error.h" #include "mystring.h" +#include "var.h" static struct job *jobtab; /* array of jobs */ @@ -798,6 +799,7 @@ forkshell(struct job *jp, union node *n, int mode) handler = &main_handler; closescript(); INTON; + forcelocal = 0; clear_traps(); #if JOBS jobctl = 0; /* do job control only in root shell */ @@ -1121,7 +1123,7 @@ backgndpidset(void) pid_t backgndpidval(void) { - if (bgjob != NULL) + if (bgjob != NULL && !forcelocal) bgjob->remembered = 1; return backgndpid; } |