diff options
-rw-r--r-- | ISSUES.markdown | 2 | ||||
-rw-r--r-- | ksh/kshrc.d/keep.ksh | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/ISSUES.markdown b/ISSUES.markdown index db98183f..0949c0b6 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -16,5 +16,3 @@ Known issues * dr(1df) is probably more practical in awk * How come commands I fix with the fc builtin always seem to exit 1 even if they succeed? Did I do that or is it Bash? -* mksh(1) when running keep() prints out variables with a "typeset" prefix - that seems to mask them when read back in 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 |