From 7424844df5496d90a6bad94a1ff5570a185ae1c1 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 1 Oct 2020 16:49:10 +0200 Subject: [PATCH] Remove SH_SUBSHELL option vestiges Mildly interesting: apparently there was once an idea to implement shared-state command substitutions as a shell option like 'set -o subshare'. They were implemented using a new ${ syntax; } instead, but there is a vestigial SH_SUBSHARE option ID in shell.h plus a check for it in subshell.c that would cause backtick-style command substitutions (comsub==1) to share their state. That option isn't defined in data/options.c so it's impossible for a user to set it. src/cmd/ksh93/include/shell.h, src/cmd/ksh93/sh/subshell.c: - Remove SH_SUBSHELL option vestiges. src/cmd/ksh93/include/defs.h: - Correct my comment on 'comsub' flag; I was wrong about what the values meant. 2 is for a shared-state comsub. (re: 4ce486a7) --- src/cmd/ksh93/include/defs.h | 4 ++-- src/cmd/ksh93/include/shell.h | 1 - src/cmd/ksh93/sh/subshell.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cmd/ksh93/include/defs.h b/src/cmd/ksh93/include/defs.h index 8eab62100..e4ea7d34b 100644 --- a/src/cmd/ksh93/include/defs.h +++ b/src/cmd/ksh93/include/defs.h @@ -211,8 +211,8 @@ struct shared unsigned char ignsig; /* ignored signal in subshell */ \ unsigned char lastsig; /* last signal received */ \ char pathinit; /* pathinit called from subshell */ \ - char comsub; /* set to 1 when in `` comsub, 2 when in $() comsub */ \ - char subshare; /* set when in ${..} comsub */ \ + char comsub; /* set to 1 when in `...`, 2 when in ${ ...; }, 3 when in $(...) */ \ + char subshare; /* set when comsub==2 (shared-state ${ ...; } command substitution) */ \ char toomany; /* set when out of fd's */ \ char instance; /* in set_instance */ \ char decomma; /* decimal_point=',' */ \ diff --git a/src/cmd/ksh93/include/shell.h b/src/cmd/ksh93/include/shell.h index 77d908dd0..15f32059d 100644 --- a/src/cmd/ksh93/include/shell.h +++ b/src/cmd/ksh93/include/shell.h @@ -86,7 +86,6 @@ typedef union Shnode_u Shnode_t; #define SH_GMACS 24 #define SH_EMACS 25 #define SH_PRIVILEGED 26 -#define SH_SUBSHARE 27 /* subshell shares state with parent */ #define SH_NOLOG 28 #define SH_NOTIFY 29 #define SH_DICTIONARY 30 diff --git a/src/cmd/ksh93/sh/subshell.c b/src/cmd/ksh93/sh/subshell.c index cd98deb04..51bc5aa16 100644 --- a/src/cmd/ksh93/sh/subshell.c +++ b/src/cmd/ksh93/sh/subshell.c @@ -523,7 +523,7 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_t *t, volatile int flags, int comsub) job.curpgid = 0; sp->subshare = shp->subshare; sp->comsub = shp->comsub; - shp->subshare = comsub==2 || (comsub==1 && sh_isoption(SH_SUBSHARE)); + shp->subshare = comsub==2; if(comsub) { shp->comsub = comsub;