aboutsummaryrefslogtreecommitdiff
path: root/ksh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-28 10:25:53 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-28 10:25:53 +1300
commit8dd33ed79da2ab397721a44f923abdcaaf55f085 (patch)
tree61a9090802a9bb3d3d3152393350934a2893973e /ksh
parentQuiet a shellcheck error (diff)
downloaddotfiles-8dd33ed79da2ab397721a44f923abdcaaf55f085.tar.gz
dotfiles-8dd33ed79da2ab397721a44f923abdcaaf55f085.zip
Deal with the kshes' varying treatment of ! in PS1
Diffstat (limited to 'ksh')
-rw-r--r--ksh/kshrc.d/prompt.ksh24
1 files changed, 22 insertions, 2 deletions
diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh
index 228fd4c5..84129efc 100644
--- a/ksh/kshrc.d/prompt.ksh
+++ b/ksh/kshrc.d/prompt.ksh
@@ -136,8 +136,28 @@ function prompt {
state=${state}'>'
# Tracked files are modified
- git diff-files --no-ext-diff --quiet ||
- state=${state}'!!'
+ if ! git diff-files --no-ext-diff --quiet ; then
+
+ # Different ksh flavours process a bang in PS1 after prompt
+ # parameter expansion in different ways
+ case $KSH_VERSION in
+
+ # ksh93 requires a double-bang to escape it
+ (*'93'*) state=${state}'!!' ;;
+
+ # OpenBSD's pdksh requires a double-bang too, but its
+ # upstream does not
+ (*'PD KSH'*)
+ case $OS in
+ ('OpenBSD') state=${state}'!!' ;;
+ (*) state=${state}'!' ;;
+ esac
+ ;;
+
+ # Everything else should need only one bang
+ (*) state=${state}'!' ;;
+ esac
+ fi
# Changes are staged
git diff-index --cached --no-ext-diff --quiet HEAD ||