aboutsummaryrefslogtreecommitdiff
path: root/ksh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-22 12:54:49 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-22 12:54:49 +1300
commit4bca2b86e31cc8949b50531bc3613e57cdc120c3 (patch)
treefc957f5eeca2b3763caa2bfc649b9bdbde40216b /ksh
parentca26e3939d64486900bba6169508b805767c69fe (diff)
downloaddotfiles-4bca2b86e31cc8949b50531bc3613e57cdc120c3.tar.gz
Limit keep() to ksh93
FreeBSD pdksh doesn't even have complete typeset -p output, nor printf %q, which I think makes this impractical.
Diffstat (limited to 'ksh')
-rw-r--r--ksh/kshrc.d/keep.ksh11
1 files changed, 9 insertions, 2 deletions
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