From 4e5f24e38ce9d0fcb965122c0f58f079a2016cb9 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 22 Jul 2020 11:46:54 +0100 Subject: [PATCH] sh/xec.c: remove inactive and broken SHOPT_AMP code This code has always been completely undocumented since it was added sometime between 2002 and 2004[*]. No one (including Google) knows what it's for and no one is likely to find out. Not only that, it doesn't compile. If SHOPT_AMP is defined, then it errors out on an undefined function `print_fun` and an undefined member `shpath` of 'struct Shell_s'. So it's clear that the code had been abandoned by its authors for some time as of 2012. src/cmd/ksh93/sh/xec.c: - Remove vestigial SHOPT_AMP stuff, whatever that was. [*] Found out by searching multishell ksh93 repo: https://github.com/multishell/ksh93/ --- src/cmd/ksh93/sh/xec.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index 4f99919bf..f13c70d7c 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -941,7 +941,7 @@ int sh_exec(register const Shnode_t *t, int flags) int execflg = (type&sh_state(SH_NOFORK)); int execflg2 = (type&sh_state(SH_FORKED)); int mainloop = (type&sh_state(SH_INTERACTIVE)); -#if SHOPT_AMP || SHOPT_SPAWN +#if SHOPT_SPAWN int ntflag = (type&sh_state(SH_NTFORK)); #else int ntflag = 0; @@ -1573,18 +1573,6 @@ int sh_exec(register const Shnode_t *t, int flags) pipes[2] = 0; coproc_init(shp,pipes); } -#if SHOPT_AMP - if((type&(FAMP|FINT)) == (FAMP|FINT)) - parent = sh_ntfork(shp,t,com,&jobid,ntflag); - else - parent = sh_fork(shp,type,&jobid); - if(parent<0) - { - if(shp->comsub==1 && usepipe && unpipe) - iounpipe(shp); - break; - } -#else #if SHOPT_SPAWN # ifdef _lib_fork if(com) @@ -1604,7 +1592,6 @@ int sh_exec(register const Shnode_t *t, int flags) #else parent = sh_fork(shp,type,&jobid); #endif /* SHOPT_SPAWN */ -#endif } if(job.parent=parent) /* This is the parent branch of fork @@ -3380,7 +3367,7 @@ static void coproc_init(Shell_t *shp, int pipes[]) #if SHOPT_SPAWN -#if SHOPT_AMP || !defined(_lib_fork) +#if !defined(_lib_fork) /* * create a shell script consisting of t->fork.forktre and execute it @@ -3490,7 +3477,7 @@ static pid_t sh_ntfork(Shell_t *shp,const Shnode_t *t,char *argv[],int *jobid,in otype = savetype; savetype=0; } -# if SHOPT_AMP || !defined(_lib_fork) +# if !defined(_lib_fork) if(!argv) { register Shnode_t *tchild = t->fork.forktre;