From 54e6b86d1541f998915bc2c34d42212c532e1f20 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 17 Dec 2016 19:52:47 +1300 Subject: Second try at compatible ksh test I guess this is my life now --- sh/shrc.d/ksh.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sh') diff --git a/sh/shrc.d/ksh.sh b/sh/shrc.d/ksh.sh index befa60ee..6c134e88 100644 --- a/sh/shrc.d/ksh.sh +++ b/sh/shrc.d/ksh.sh @@ -11,12 +11,10 @@ # proceed ... if [ -z "$KSH_VERSION" ] ; then - # Do we have the '[[' builtin? Good start - command -v '[[' >/dev/null 2>&1 || return - - # Use the '[[' builtin to test whether $.sh.version is set (yes, that's a - # real variable name) - [[ -v .sh.version ]] || return + # 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} -- cgit v1.2.3