From 08ae35be0a8e42a1b234d3a54a2aceca17fe11f8 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 4 Sep 2024 00:06:51 +0100 Subject: [PATCH] Remove SHOPT_SYSRC probe, enable by default It's just not right that it depends on the presence of /etc/ksh.kshrc or even /etc/bash.bashrec on the build machine whether /etc/ksh.kshrc is going to be loaded at startup on the users' machine. src/cmd/ksh93/Mamfile: - Remove SHOPT_SYSRC probe code. src/cmd/ksh93/SHOPT.sh: - Enable SHOPT_SYSRC by default. README.md: - Document that SHOPT_SYSRC should be disabled on systems with a default incompatible /etc/ksh.kshrc. Resolves: https://github.com/ksh93/ksh/issues/776 --- README.md | 6 ++++++ src/cmd/ksh93/Mamfile | 5 ----- src/cmd/ksh93/README | 5 ++--- src/cmd/ksh93/SHOPT.sh | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7a03bd8ff666..1432c1af548d 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ For known issues in the current release, see [TODO](https://github.com/ksh93/ksh To build ksh with a custom configuration of features, edit [`src/cmd/ksh93/SHOPT.sh`](https://github.com/ksh93/ksh/blob/1.0/src/cmd/ksh93/SHOPT.sh). +On systems such as NetBSD and OpenBSD, where `/bin/ksh` is not ksh93 and the +preinstalled `/etc/ksh.kshrc` profile script is incompatible with ksh93, you'll +want to disable `SHOPT_SYSRC` to avoid loading it on startup -- unless you can +edit it to make it compatible with ksh93. This geneerally involves differences +in the declaration and usage of local variables in functions. + Then `cd` to the top directory and run: ``` diff --git a/src/cmd/ksh93/Mamfile b/src/cmd/ksh93/Mamfile index 355fdce28b3f..75f8b962c28a 100644 --- a/src/cmd/ksh93/Mamfile +++ b/src/cmd/ksh93/Mamfile @@ -118,11 +118,6 @@ make install virtual exec - -zutalors) exec - writedef PRINTF_LEGACY 1 ;; exec - esac ;; - exec - 'SYSRC=') - exec - # if one of these exists, make SHOPT_SYSRC load /etc/ksh.kshrc by default - exec - if test -f /etc/ksh.kshrc || test -f /etc/bash.bashrc - exec - then writedef SYSRC 1 - exec - fi ;; exec - # some other SHOPTs may be probed for using feature tests in features/options exec - *=?*) exec - writedef "$n" "$v" ;; diff --git a/src/cmd/ksh93/README b/src/cmd/ksh93/README index eee87c704bb6..1a0c296a326a 100644 --- a/src/cmd/ksh93/README +++ b/src/cmd/ksh93/README @@ -154,9 +154,8 @@ The options have the following defaults and meanings: STATS on Add .sh.stats compound variable. - SYSRC Source /etc/ksh.kshrc on initializing an interactive - shell. This is on by default if /etc/ksh.kshrc or - /etc/bash.bashrc exists at compile time. + SYSRC on Source /etc/ksh.kshrc on initializing an interactive + shell. TEST_L Add 'test -l' as an alias for 'test -L'. This is on by default if the OS's external 'test' command supports it. diff --git a/src/cmd/ksh93/SHOPT.sh b/src/cmd/ksh93/SHOPT.sh index 3c97afcea20e..045c905f5f84 100644 --- a/src/cmd/ksh93/SHOPT.sh +++ b/src/cmd/ksh93/SHOPT.sh @@ -37,7 +37,7 @@ SHOPT REMOTE= # enable --rc if running as a remote shell SHOPT SCRIPTONLY=0 # build ksh for running scripts only; compile out the interactive shell SHOPT SPAWN= # use spawnveg for fork/exec SHOPT STATS=1 # add .sh.stats variable -SHOPT SYSRC= # attempt . /etc/ksh.kshrc if interactive +SHOPT SYSRC=1 # attempt . /etc/ksh.kshrc if interactive SHOPT TEST_L= # add 'test -l' as an alias for 'test -L' SHOPT TIMEOUT= # number of seconds for shell timeout SHOPT VSH=1 # vi edit mode