mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
Turn off SH_INTERACTIVE state flag in subshells
By definition, subshells are never interactive, so they should disable behaviour associated with interactive shells even if the main shell is interactive. Most visibly, running a background job from a subshell like ( some_command & ) now no longer prints a job ID that you cannot use in the main shell. This behaviour change matches pdksh/mksh, bash, zsh, dash, et al. Prior discussion: https://www.mail-archive.com/austin-group-l@opengroup.org/msg06456.html (plus the preceding thread) src/cmd/ksh93/sh/subshell.c: sh_subshell(): - Before running the command(s) in the subshell using sh_exec(), turn off the SH_INTERACTIVE shell state flag. (No need to add code to restore it as this function already saves and restores the entire shell state.) src/cmd/ksh93/bltins/misc.c: b_bg(): - If there is no job control when using 'bg', 'fg' or 'disown', always print the "no job control" error message and not only if the shell is in the interactive state. This is also what pdksh/mksh, bash and zsh do.
This commit is contained in:
parent
7424844df5
commit
48ba6964ad
2 changed files with 2 additions and 2 deletions
|
@ -418,8 +418,7 @@ int b_bg(register int n,register char *argv[],Shbltin_t *context)
|
|||
argv += opt_info.index;
|
||||
if(!sh_isoption(SH_MONITOR) || !job.jobcontrol)
|
||||
{
|
||||
if(sh_isstate(SH_INTERACTIVE))
|
||||
errormsg(SH_DICT,ERROR_exit(1),e_no_jctl);
|
||||
errormsg(SH_DICT,ERROR_exit(1),e_no_jctl);
|
||||
return(1);
|
||||
}
|
||||
if(flag=='d' && *argv==0)
|
||||
|
|
|
@ -633,6 +633,7 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_t *t, volatile int flags, int comsub)
|
|||
if(shp->savesig < 0)
|
||||
{
|
||||
shp->savesig = 0;
|
||||
sh_offstate(SH_INTERACTIVE);
|
||||
sh_exec(t,flags);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue