From 5ab5ccd94bda49db30e7c600364cc4e14e88df9b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 17 Dec 2016 20:03:40 +1300 Subject: Move ksh.sh shim into ksh subdir So it doesn't get installed on systems where I don't use ksh, since it's mostly not needed --- Makefile | 2 ++ README.markdown | 5 ++--- ksh/shrc.d/ksh.sh | 30 ++++++++++++++++++++++++++++++ sh/shrc.d/ksh.sh | 30 ------------------------------ 4 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 ksh/shrc.d/ksh.sh delete mode 100644 sh/shrc.d/ksh.sh diff --git a/Makefile b/Makefile index f2e9e278..9961da71 100644 --- a/Makefile +++ b/Makefile @@ -292,7 +292,9 @@ install-mysql : install-ksh : check-ksh install-sh install -m 0755 -d -- \ + "$(HOME)"/.shrc.d \ "$(HOME)"/.kshrc.d + install -pm 0644 -- ksh/shrc.d/* "$(HOME)"/.shrc.d install -pm 0644 -- ksh/kshrc "$(HOME)"/.kshrc install -pm 0644 -- ksh/kshrc.d/* "$(HOME)"/.kshrc.d diff --git a/README.markdown b/README.markdown index 5c9dc392..fb517bad 100644 --- a/README.markdown +++ b/README.markdown @@ -255,9 +255,8 @@ Otherwise, they're all loaded on startup. #### Korn shell -The `ksh` configuration files and functions are not nearly as featureful as the -Bash ones. At the moment these are mainly being maintained for use on OpenBSD -`pdksh`. +These are experimental; they are mostly used to tinker with MirBSD `mksh`, AT&T +`ksh93`, and OpenBSD `pdksh`. `ksh`, `ksh93`, `pdksh`, and `mksh` shells default to having a prompt coloured yellow. diff --git a/ksh/shrc.d/ksh.sh b/ksh/shrc.d/ksh.sh new file mode 100644 index 00000000..6c134e88 --- /dev/null +++ b/ksh/shrc.d/ksh.sh @@ -0,0 +1,30 @@ +# If we're running some kind of ksh, we'll need to source its specific +# configuration if it was defined or if we can find it. Bash and Zsh invoke +# their own rc files first, which I've written to then look for ~/.shrc; ksh +# does it the other way around. + +# Unfortunately, this isn't very simple, because KSH_VERSION is set by PDKSH +# and derivatives, and in ksh93t+ and above, but not in earlier versions of +# ksh93. + +# If it's not already set, we'll try hard to set it to something before we +# proceed ... +if [ -z "$KSH_VERSION" ] ; then + + # Test whether we have content in the .sh.version variable. The odd name + # causes at least Bash to panic, so we suppress errors, and we run it in a + # subshell to work around parsing error precedence. + ( test -n "${.sh.version}" ) 2>/dev/null || return + + # If it is, that's our KSH_VERSION + KSH_VERSION=${.sh.version} +fi + +# If KSH_ENV isn't already set, set it +[ -n "$KSH_ENV" ] || KSH_ENV=$HOME/.kshrc + +# Check the file named in KSH_ENV exists +[ -f "$KSH_ENV" ] || return + +# Source it (finally) +. "$KSH_ENV" diff --git a/sh/shrc.d/ksh.sh b/sh/shrc.d/ksh.sh deleted file mode 100644 index 6c134e88..00000000 --- a/sh/shrc.d/ksh.sh +++ /dev/null @@ -1,30 +0,0 @@ -# If we're running some kind of ksh, we'll need to source its specific -# configuration if it was defined or if we can find it. Bash and Zsh invoke -# their own rc files first, which I've written to then look for ~/.shrc; ksh -# does it the other way around. - -# Unfortunately, this isn't very simple, because KSH_VERSION is set by PDKSH -# and derivatives, and in ksh93t+ and above, but not in earlier versions of -# ksh93. - -# If it's not already set, we'll try hard to set it to something before we -# proceed ... -if [ -z "$KSH_VERSION" ] ; then - - # Test whether we have content in the .sh.version variable. The odd name - # causes at least Bash to panic, so we suppress errors, and we run it in a - # subshell to work around parsing error precedence. - ( test -n "${.sh.version}" ) 2>/dev/null || return - - # If it is, that's our KSH_VERSION - KSH_VERSION=${.sh.version} -fi - -# If KSH_ENV isn't already set, set it -[ -n "$KSH_ENV" ] || KSH_ENV=$HOME/.kshrc - -# Check the file named in KSH_ENV exists -[ -f "$KSH_ENV" ] || return - -# Source it (finally) -. "$KSH_ENV" -- cgit v1.2.3