aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-18 13:42:10 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-18 13:42:10 +1300
commitd35b7a1e1e2c8baed5d1861886ae5b860494ee0f (patch)
treead24f4eb0fa30c4dbc175753a2c34cc94fc57ccd
parentMerge branch 'master' into openbsd (diff)
parentAdd ksh version distinguisher to prompt (diff)
downloaddotfiles-d35b7a1e1e2c8baed5d1861886ae5b860494ee0f.tar.gz
dotfiles-d35b7a1e1e2c8baed5d1861886ae5b860494ee0f.zip
Merge branch 'master' into openbsd
-rw-r--r--ISSUES.markdown2
-rw-r--r--games/drakon.awk4
-rw-r--r--ksh/kshrc.d/prompt.ksh16
-rw-r--r--sh/profile4
4 files changed, 19 insertions, 7 deletions
diff --git a/ISSUES.markdown b/ISSUES.markdown
index 19375c83..b02db22e 100644
--- a/ISSUES.markdown
+++ b/ISSUES.markdown
@@ -18,3 +18,5 @@ 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?
+* typeset in ksh93 does not seem to make the variable local, maybe I'm
+ missing some magic
diff --git a/games/drakon.awk b/games/drakon.awk
index 39bb3732..4b8c35c5 100644
--- a/games/drakon.awk
+++ b/games/drakon.awk
@@ -2,11 +2,11 @@
# <http://www.adomgb.info/adomgb-4.html>
{
line = ""
- case = 0
+ toggle = 0
for (i = 1; i <= length; i++) {
char = substr($0, i, 1)
if (char ~ /[a-zA-Z]/)
- char = (case = !case) ? tolower(char) : toupper(char)
+ char = (toggle = !toggle) ? tolower(char) : toupper(char)
line = line char
}
print line
diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh
index 942868a5..32bb8192 100644
--- a/ksh/kshrc.d/prompt.ksh
+++ b/ksh/kshrc.d/prompt.ksh
@@ -1,5 +1,5 @@
# Frontend to controlling prompt
-prompt() {
+function prompt {
# If no arguments, print the prompt strings as they are
if ! (($#)) ; then
@@ -19,8 +19,8 @@ prompt() {
fi
# Add sub-commands; working directory with ~ abbreviation, VCS,
- # job, and return status checks
- PS1=$PS1'$(prompt pwd)$(prompt vcs)$(prompt job)'
+ # job, and ksh version code
+ PS1=$PS1'$(prompt pwd)$(prompt vcs)$(prompt job)$(prompt ver)'
# If this is PDKSH, add the exit code of the previous command; this
# doesn't seem to work on ksh93, probably different timing for when
@@ -203,6 +203,16 @@ prompt() {
((jobc)) && printf '{%u}' "$jobc"
;;
+ # Show a short code denoting the ksh flavour, if it can be gleaned from
+ # KSH_VERSION
+ ver)
+ case $KSH_VERSION in
+ *'PD KSH'*) printf %s ':pd' ;;
+ *'MIRBSD KSH'*) printf %s ':mk' ;;
+ *' 93'*) printf %s ':93' ;;
+ esac
+ ;;
+
# Print error
*)
printf 'prompt: Unknown command %s\n' "$1" >&2
diff --git a/sh/profile b/sh/profile
index fd87b8fa..5d9c80bf 100644
--- a/sh/profile
+++ b/sh/profile
@@ -7,8 +7,8 @@ for sh in "$HOME"/.profile.d/*.sh ; do
done
unset -v sh
-# If ENV is still unset, and ~/.shinit exists, use that
-if [ -z "$ENV" ] && [ -f "$HOME"/.shinit ] ; then
+# If ~/.shinit exists, set ENV to that
+if [ -f "$HOME"/.shinit ] ; then
ENV=$HOME/.shinit
export ENV
fi