aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-28 10:27:24 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-28 10:27:24 +1300
commit79d73392a91c802292c733cb98c607d633148a1d (patch)
tree61a9090802a9bb3d3d3152393350934a2893973e
parentChange quoting mechanism (diff)
parentDeal with the kshes' varying treatment of ! in PS1 (diff)
downloaddotfiles-79d73392a91c802292c733cb98c607d633148a1d.tar.gz
dotfiles-79d73392a91c802292c733cb98c607d633148a1d.zip
Merge branch 'master' into port/bsd/openbsd
-rw-r--r--.gitignore2
-rw-r--r--ISSUES.markdown4
-rw-r--r--Makefile16
-rw-r--r--README.markdown4
-rw-r--r--bin/max.awk10
-rw-r--r--bin/min.awk10
-rwxr-xr-xcheck/zsh6
-rw-r--r--ksh/kshrc.d/prompt.ksh25
-rwxr-xr-xlint/zsh2
-rw-r--r--man/man1/max.1df19
-rw-r--r--man/man1/min.1df19
-rw-r--r--sh/profile.d/os.sh3
12 files changed, 113 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index d7a435fa..110f8c4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,9 +2,11 @@ bin/csmw
bin/ddup
bin/gwp
bin/han
+bin/max
bin/mean
bin/med
bin/mftl
+bin/min
bin/mode
bin/rfct
bin/rndi
diff --git a/ISSUES.markdown b/ISSUES.markdown
index 5d9d43d3..97eed594 100644
--- a/ISSUES.markdown
+++ b/ISSUES.markdown
@@ -20,7 +20,11 @@ Known issues
manageable
* On non-OBSD pdksh and mksh, !! comes out as literal !! after subshell
expansion; a version switch might be necessary
+ * Or using a different character
* Running the block of git(1) commands in the prompt leaves five "stale"
jobspecs around that flee after a jobs builtin run; only saw this manifest
after 90dcadf; either I understand job specs really poorly or this may be a
bug in bash
+* The directory navigation tools may not be handling directories with
+ terminal newlines in their names due to subshell expansion chomping them;
+ could maybe fix this by adding a slash to what's returned
diff --git a/Makefile b/Makefile
index 30183494..da6b043a 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,7 @@
check-sh \
check-urxvt \
check-yash \
+ check-zsh \
lint \
lint-bash \
lint-bin \
@@ -70,9 +71,11 @@ all : bin/csmw \
bin/ddup \
bin/gwp \
bin/han \
+ bin/max \
bin/mean \
bin/med \
bin/mftl \
+ bin/min \
bin/mode \
bin/rfct \
bin/rndi \
@@ -92,9 +95,11 @@ clean distclean :
bin/ddup \
bin/gwp \
bin/han \
+ bin/max \
bin/mean \
bin/med \
bin/mftl \
+ bin/min \
bin/mode \
bin/rfct \
bin/rndi \
@@ -192,9 +197,9 @@ install-bash-completion : install-bash
install -pm 0644 -- bash/bash_completion "$(HOME)"/.config/bash_completion
install -pm 0644 -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d
-install-bin : bin/csmw bin/ddup bin/gwp bin/han bin/mean bin/med bin/mftl \
- bin/mode bin/rfct bin/rndi bin/sd2u bin/sec bin/slsf bin/su2d bin/tot \
- bin/unf bin/uts install-bin-man
+install-bin : bin/csmw bin/ddup bin/gwp bin/han bin/max bin/mean bin/med \
+ bin/mftl bin/min bin/mode bin/rfct bin/rndi bin/sd2u bin/sec bin/slsf \
+ bin/su2d bin/tot bin/unf bin/uts install-bin-man
install -m 0755 -d -- "$(HOME)"/.local/bin
for name in bin/* ; do \
[ -x "$$name" ] || continue ; \
@@ -388,7 +393,7 @@ install-yash : check-yash install-sh
install -pm 0644 -- yash/yashrc "$(HOME)"/.yashrc
install -pm 0644 -- yash/yashrc.d/* "$(HOME)"/.yashrc.d
-install-zsh : install-sh
+install-zsh : check-zsh install-sh
install -m 0755 -d -- "$(HOME)"/.zshrc.d
install -pm 0644 -- zsh/zprofile "$(HOME)"/.zprofile
install -pm 0644 -- zsh/zshrc "$(HOME)"/.zshrc
@@ -425,6 +430,9 @@ check-urxvt :
check-yash :
check/yash
+check-zsh :
+ check/zsh
+
lint : check \
lint-bash \
lint-bin \
diff --git a/README.markdown b/README.markdown
index 109af073..777d5dd1 100644
--- a/README.markdown
+++ b/README.markdown
@@ -394,9 +394,11 @@ Installed by the `install-bin` target:
* `unf(1df)` joins lines with leading spaces to the previous line.
Intended for unfolding HTTP headers, but it should work for most RFC
822 formats.
-* Four simple aggregators for numbers:
+* Six simple aggregators for numbers:
+ * `max(1df)` prints the maximum.
* `mean(1df)` prints the mean.
* `med(1df)` prints the median.
+ * `min(1df)` prints the minimum.
* `mode(1df)` prints the first encountered mode.
* `tot(1df)` totals the set.
* `ap(1df)` reads arguments for a given command from the standard input,
diff --git a/bin/max.awk b/bin/max.awk
new file mode 100644
index 00000000..11d4efd9
--- /dev/null
+++ b/bin/max.awk
@@ -0,0 +1,10 @@
+# Get the maximum of a list of numbers
+{
+ if (NR == 1 || $1 > max)
+ max = $1
+}
+END {
+ if (!NR)
+ exit(1)
+ print max
+}
diff --git a/bin/min.awk b/bin/min.awk
new file mode 100644
index 00000000..c58a3a8f
--- /dev/null
+++ b/bin/min.awk
@@ -0,0 +1,10 @@
+# Get the minimum of a list of numbers
+{
+ if (NR == 1 || $1 < min)
+ min = $1
+}
+END {
+ if (!NR)
+ exit(1)
+ print min
+}
diff --git a/check/zsh b/check/zsh
new file mode 100755
index 00000000..39a6c1e9
--- /dev/null
+++ b/check/zsh
@@ -0,0 +1,6 @@
+#!/bin/sh
+for zsh in zsh/* zsh/zshrc.d/* ; do
+ [ -f "$zsh" ] || continue
+ zsh -n "$zsh" || exit
+done
+printf 'All zsh(1) scripts parsed successfully.\n'
diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh
index add96b2a..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 ||
@@ -192,6 +212,7 @@ function prompt {
# Show the count of background jobs in curly brackets, if not zero
job)
+ # shellcheck disable=SC2154
((jobc)) && printf '{%u}' "$jobc"
;;
diff --git a/lint/zsh b/lint/zsh
new file mode 100755
index 00000000..9f6af707
--- /dev/null
+++ b/lint/zsh
@@ -0,0 +1,2 @@
+#!/bin/sh
+find zsh -type f -print -exec shellcheck -e SC1090 -s ksh -- {} \;
diff --git a/man/man1/max.1df b/man/man1/max.1df
new file mode 100644
index 00000000..28431da4
--- /dev/null
+++ b/man/man1/max.1df
@@ -0,0 +1,19 @@
+.TH MAX 1df "September 2016" "Manual page for max"
+.SH NAME
+.B max
+\- print the maximum of a list of numbers
+.SH SYNOPSIS
+printf '%u\\n' 3 55 17 |
+.B max
+.br
+.B max
+file
+.br
+.B max
+file1 file2
+.SH DESCRIPTION
+.B max
+collects all the newline-delimited numbers given as input, and prints the
+maximum.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/min.1df b/man/man1/min.1df
new file mode 100644
index 00000000..e3279d3b
--- /dev/null
+++ b/man/man1/min.1df
@@ -0,0 +1,19 @@
+.TH MIN 1df "September 2016" "Manual page for min"
+.SH NAME
+.B min
+\- print the minimum of a list of numbers
+.SH SYNOPSIS
+printf '%u\\n' 182 2 22 |
+.B min
+.br
+.B min
+file
+.br
+.B min
+file1 file2
+.SH DESCRIPTION
+.B min
+collects all the newline-delimited numbers given as input, and prints the
+minimum.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/sh/profile.d/os.sh b/sh/profile.d/os.sh
new file mode 100644
index 00000000..f9d5a79b
--- /dev/null
+++ b/sh/profile.d/os.sh
@@ -0,0 +1,3 @@
+# Store the operating system in an environment variable
+OS=$(uname)
+export OS