From 4bca2b86e31cc8949b50531bc3613e57cdc120c3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 22 Dec 2016 12:54:49 +1300 Subject: Limit keep() to ksh93 FreeBSD pdksh doesn't even have complete typeset -p output, nor printf %q, which I think makes this impractical. --- ksh/kshrc.d/keep.ksh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ksh/kshrc.d/keep.ksh') diff --git a/ksh/kshrc.d/keep.ksh b/ksh/kshrc.d/keep.ksh index f89cbc95..3c1ca199 100644 --- a/ksh/kshrc.d/keep.ksh +++ b/ksh/kshrc.d/keep.ksh @@ -1,3 +1,10 @@ +# Limit to ksh93; most of this works in mksh, but not all of it, and pdksh +# doesn't have a `typeset -p` that includes printable values at all. +case $KSH_VERSION in + *' 93'*) ;; + *) return ;; +esac + # # keep -- Main function for kshkeep; provided with a list of NAMEs, whether # shell functions or variables, writes the current definition of each NAME to a @@ -114,7 +121,7 @@ EOF ((errors++)) # Save a variable - elif [[ -n "$name" ]] ; then + elif [[ -v "$name" ]] ; then typeset -p -- "$name" >"$kshkeep"/"$name".ksh || ((errors++)) fi @@ -147,6 +154,6 @@ EOF # Load any existing scripts in kshkeep for kshkeep in "${KSHKEEP:-"$HOME"/.kshkeep.d}"/*.ksh ; do - [[ -e $kshkeep ]] && . "$kshkeep" + [[ -e $kshkeep ]] && source "$kshkeep" done unset -v kshkeep -- cgit v1.2.3