From 0e197eee57041b13ef7227a71335e8d113e6e54a Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Tue, 28 Dec 2021 08:53:30 -0800 Subject: [PATCH] Fix `mkservice` compile errors and add `SHOPT_MKSERVICE` (#401) The unused mkservice and eloop builtins are currently not built, and if an attempt to compile them is made the build ends in failure. This commit backports a few build fixes from ksh93v- 2012-08-24 that allow mkservice and eloop to build (plus an additional compiler warning fix not in ksh93v-). I've also added a new SHOPT_MKSERVICE setting (turned off by default) so that mkservice and eloop can be built if the user chooses to include them in their build of ksh. --- NEWS | 3 +++ src/cmd/ksh93/Mamfile | 14 +++++++++++++- src/cmd/ksh93/README | 5 +++++ src/cmd/ksh93/SHOPT.sh | 1 + src/cmd/ksh93/bltins/mkservice.c | 10 +++++++--- src/cmd/ksh93/data/builtins.c | 4 ++++ src/cmd/ksh93/include/builtins.h | 4 ++++ 7 files changed, 37 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 223bbf37f..55c7147d7 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,9 @@ Any uppercase BUG_* names are modernish shell bug IDs. xtrace (set -x) is on and the $PS4 prompt contains parameter expansions or command substitutions. +- The mkservice and eloop builtins can now be built by enabling the + new SHOPT_MKSERVICE setting in src/cmd/ksh93/SHOPT.sh. + 2021-12-26: - Listing aliases or tracked aliases in a script no longer corrupts diff --git a/src/cmd/ksh93/Mamfile b/src/cmd/ksh93/Mamfile index 7f80c3147..edb9e6e16 100644 --- a/src/cmd/ksh93/Mamfile +++ b/src/cmd/ksh93/Mamfile @@ -421,6 +421,18 @@ make install prev SHOPT.sh exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${KSH_SHOPTFLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -D_API_ast=20100309 -D_PACKAGE_ast -DERROR_CONTEXT_T=Error_context_t -c bltins/misc.c done misc.o generated + make mkservice.o + make bltins/mkservice.c + prev ${PACKAGE_ast_INCLUDE}/cmd.h implicit + prev ${PACKAGE_ast_INCLUDE}/error.h implicit + prev include/nval.h implicit + prev include/defs.h implicit + done bltins/mkservice.c + meta mkservice.o %.c>%.o bltins/mkservice.c mkservice + prev bltins/mkservice.c + prev SHOPT.sh + exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${KSH_SHOPTFLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DSH_DICT=${SH_DICT} -D_PACKAGE_ast -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -c bltins/mkservice.c + done mkservice.o generated make print.o make bltins/print.c make ${PACKAGE_ast_INCLUDE}/ccode.h implicit @@ -1364,7 +1376,7 @@ make install prev SHOPT.sh exec - ${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${KSH_SHOPTFLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -D_PACKAGE_ast -D_API_ast=20100309 -DERROR_CONTEXT_T=Error_context_t -c edit/hexpand.c done hexpand.o generated - exec - ${AR} rc libshell.a alarm.o cd_pwd.o cflow.o deparse.o enum.o getopts.o hist.o misc.o print.o read.o sleep.o trap.o test.o typeset.o ulimit.o umask.o whence.o main.o nvdisc.o nvtype.o arith.o args.o array.o completion.o defs.o edit.o expand.o regress.o fault.o fcin.o + exec - ${AR} rc libshell.a alarm.o cd_pwd.o cflow.o deparse.o enum.o getopts.o hist.o misc.o mkservice.o print.o read.o sleep.o trap.o test.o typeset.o ulimit.o umask.o whence.o main.o nvdisc.o nvtype.o arith.o args.o array.o completion.o defs.o edit.o expand.o regress.o fault.o fcin.o exec - ${AR} rc libshell.a history.o init.o io.o jobs.o lex.o macro.o name.o nvtree.o parse.o path.o string.o streval.o subshell.o tdump.o timers.o trestore.o waitevent.o xec.o limits.o msg.o strdata.o testops.o keywords.o options.o signals.o aliases.o builtins.o variables.o lexstates.o emacs.o vi.o hexpand.o exec - (ranlib libshell.a) >/dev/null 2>&1 || true done libshell.a generated diff --git a/src/cmd/ksh93/README b/src/cmd/ksh93/README index 9dbb8ab7a..949c49611 100644 --- a/src/cmd/ksh93/README +++ b/src/cmd/ksh93/README @@ -106,6 +106,11 @@ The options have the following defaults and meanings: .ExampleSpace.function or ${.ExampleSpace.variable}. Name spaces within name spaces are also supported. + MKSERVICE off Enables the 'mkservice' builtin which creates a TCP or UDP + server that is implemented by shell functions, and the + 'eloop' builtin which causes the shell to block waiting for + events to process. Experimental and probably insecure. + NOECHOE off Disable the '-e' option to the 'echo' command, unless SHOPT_ECHOPRINT is enabled. diff --git a/src/cmd/ksh93/SHOPT.sh b/src/cmd/ksh93/SHOPT.sh index aff451dd3..23a6ec0a0 100644 --- a/src/cmd/ksh93/SHOPT.sh +++ b/src/cmd/ksh93/SHOPT.sh @@ -25,6 +25,7 @@ SHOPT FIXEDARRAY=1 # fixed dimension indexed array SHOPT GLOBCASEDET= # -o globcasedetect: adapt globbing/completion to case-insensitive file systems SHOPT HISTEXPAND=1 # csh-style history file expansions SHOPT KIA= # ksh -R