aboutsummaryrefslogtreecommitdiff
path: root/ksh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-01-01 01:11:08 +1300
committerTom Ryder <tom@sanctum.geek.nz>2019-01-01 01:11:08 +1300
commite19bb8fb3c8350bee288327abd978a59eb3dc0f7 (patch)
tree754d2d883b27477f53f0fece44ef9edc7e4238f0 /ksh
parentMerge branch 'release/v4.2.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-4.3.0.tar.gz (sig)
dotfiles-4.3.0.zip
Merge branch 'release/v4.3.0'v4.3.0
* release/v4.3.0: Bump VERSION Switch to using GNU Emacs on development machines Trim some trailing whitespace Clarify control flow in shell scripts Add clarifying comment Translate a short-circuit into a conditional Add a cheeky error message to sd() Strip trailing slashes from sd() target Correct error message from sd()
Diffstat (limited to 'ksh')
-rw-r--r--ksh/kshrc.d/prompt.ksh40
-rw-r--r--ksh/shrc.d/ksh.sh4
2 files changed, 30 insertions, 14 deletions
diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh
index c5f3ee1b..99e6238d 100644
--- a/ksh/kshrc.d/prompt.ksh
+++ b/ksh/kshrc.d/prompt.ksh
@@ -117,27 +117,34 @@ function prompt {
# Check various files in .git to flag processes
typeset proc
- [[ -d .git/rebase-merge || -d .git/rebase-apply ]] &&
+ if [[ -d .git/rebase-merge || -d .git/rebase-apply ]] ; then
proc=${proc:+"$proc",}'REBASE'
- [[ -f .git/MERGE_HEAD ]] &&
+ fi
+ if [[ -f .git/MERGE_HEAD ]] ; then
proc=${proc:+"$proc",}'MERGE'
- [[ -f .git/CHERRY_PICK_HEAD ]] &&
+ fi
+ if [[ -f .git/CHERRY_PICK_HEAD ]] ; then
proc=${proc:+"$proc",}'PICK'
- [[ -f .git/REVERT_HEAD ]] &&
+ fi
+ if [[ -f .git/REVERT_HEAD ]] ; then
proc=${proc:+"$proc",}'REVERT'
- [[ -f .git/BISECT_LOG ]] &&
+ fi
+ if [[ -f .git/BISECT_LOG ]] ; then
proc=${proc:+"$proc",}'BISECT'
+ fi
# Collect symbols representing repository state
typeset state
# Upstream HEAD has commits after local HEAD; we're "behind"
- (($(git rev-list --count 'HEAD..@{u}'))) &&
+ if (($(git rev-list --count 'HEAD..@{u}'))) ; then
state=${state}'<'
+ fi
# Local HEAD has commits after upstream HEAD; we're "ahead"
- (($(git rev-list --count '@{u}..HEAD'))) &&
+ if (($(git rev-list --count '@{u}..HEAD'))) ; then
state=${state}'>'
+ fi
# Tracked files are modified
if ! git diff-files --no-ext-diff --quiet ; then
@@ -164,17 +171,20 @@ function prompt {
fi
# Changes are staged
- git diff-index --cached --no-ext-diff --quiet HEAD ||
+ if ! git diff-index --cached --no-ext-diff --quiet HEAD ; then
state=${state}'+'
+ fi
# There are some untracked and unignored files
- git ls-files --directory --error-unmatch --exclude-standard \
- --no-empty-directory --others -- ':/*' &&
+ if git ls-files --directory --error-unmatch --exclude-standard \
+ --no-empty-directory --others -- ':/*' ; then
state=${state}'?'
+ fi
# There are stashed changes
- git rev-parse --quiet --verify refs/stash &&
+ if git rev-parse --quiet --verify refs/stash ; then
state=${state}'^'
+ fi
} >/dev/null 2>&1
@@ -214,13 +224,17 @@ function prompt {
# Show return status of previous command in angle brackets, if not zero
ret)
# shellcheck disable=SC2154
- ((ret)) && printf '<%u>' "$ret"
+ if ((ret)) ; then
+ printf '<%u>' "$ret"
+ fi
;;
# Show the count of background jobs in curly brackets, if not zero
job)
# shellcheck disable=SC2154
- ((jobc)) && printf '{%u}' "$jobc"
+ if ((jobc)) ; then
+ printf '{%u}' "$jobc"
+ fi
;;
# Print error
diff --git a/ksh/shrc.d/ksh.sh b/ksh/shrc.d/ksh.sh
index 5ad14b9c..9e032756 100644
--- a/ksh/shrc.d/ksh.sh
+++ b/ksh/shrc.d/ksh.sh
@@ -29,4 +29,6 @@ if [ -z "$KSH_VERSION" ] ; then
fi
# If ENV_EXT isn't already set, set it
-[ -n "$ENV_EXT" ] || ENV_EXT=$HOME/.kshrc
+if [ -z "$ENV_EXT" ] ; then
+ ENV_EXT=$HOME/.kshrc
+fi