aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-01-15 12:31:26 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-01-15 12:31:26 +1300
commit99c655cd11cd9000a496bde9c9fced98308c6454 (patch)
treedfec0895cc9448af3c8eb6ffb7eac0b662315456
parentMerge branch 'hotfix/v0.22.1' (diff)
parentBump version number to 0.23.0 (diff)
downloaddotfiles-99c655cd11cd9000a496bde9c9fced98308c6454.tar.gz
dotfiles-99c655cd11cd9000a496bde9c9fced98308c6454.zip
Merge branch 'release/v0.23.0'v0.23.0
* release/v0.23.0: Bump version number to 0.23.0 Remove unused `self` var from clog(1df) Change double-quote printf pattern to single-quote Move ShellCheck line to correct place in sra(1df) Quote EDITOR/VISUAL assignments for clarity Explicitly ignore uninteresting tree(1) opts Refactor clog(1df), allow args and non-term stdin Reimplement bl(1df) in Awk Separate ax(1df) manpage args from command Make newline explicit for ax(1df) Make first ax(1df) arg safer, warn on second arg Correct monospaced blocks in Vim plugin docs
-rw-r--r--VERSION4
-rw-r--r--bin/ax.sh17
-rw-r--r--bin/bl.awk5
-rw-r--r--bin/bl.sh10
-rw-r--r--bin/clog.sh24
-rw-r--r--bin/sra.sh3
-rw-r--r--bin/sshi.sh2
-rw-r--r--man/man1/ax.1df12
-rw-r--r--man/man1/clog.1df20
-rw-r--r--sh/profile.d/editor.sh6
-rw-r--r--sh/profile.d/visual.sh2
-rw-r--r--sh/shrc.d/tree.sh1
-rw-r--r--vim/doc/copy_linebreak.txt4
-rw-r--r--vim/doc/mail_mutt.txt2
-rw-r--r--vim/doc/strip_trailing_whitespace.txt2
15 files changed, 61 insertions, 53 deletions
diff --git a/VERSION b/VERSION
index bf19fa24..5320e1b1 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v0.22.1
-Fri Dec 29 01:10:55 UTC 2017
+tejr dotfiles v0.23.0
+Sun Jan 14 23:30:34 UTC 2018
diff --git a/bin/ax.sh b/bin/ax.sh
index 6ce1e9ea..0007cbed 100644
--- a/bin/ax.sh
+++ b/bin/ax.sh
@@ -3,8 +3,8 @@
# Count arguments
case $# in
- # If one argument, we assume format is %s
- 1) form=%s expr=$1 ;;
+ # If one argument, we assume format is %s\n
+ 1) form='%s\n' expr=$1 ;;
# If two arguments, first is format, second expression
2) form=$1 expr=$2 ;;
@@ -16,12 +16,7 @@ case $# in
;;
esac
-# Form program
-prog=$(printf '
- BEGIN {
- printf "%s\\n", %s
- }
-' "$form" "$expr")
-
-# Run program
-awk "$prog"
+# Important note: there's little stopping the user from putting a fully-fledged
+# Awk program into the expression; don't use this anywhere that code injection
+# could wreck your life. See manual page ax(1df).
+awk -v form="$form" 'BEGIN{printf form,('"$expr"');exit}'
diff --git a/bin/bl.awk b/bin/bl.awk
new file mode 100644
index 00000000..0be2fc6e
--- /dev/null
+++ b/bin/bl.awk
@@ -0,0 +1,5 @@
+# Generate blank lines
+BEGIN {
+ while (ARGV[1]--)
+ print ""
+}
diff --git a/bin/bl.sh b/bin/bl.sh
deleted file mode 100644
index 6dd3d687..00000000
--- a/bin/bl.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-# Generate blank lines
-if [ "$#" -ne 1 ] || [ "$1" -lt 0 ] ; then
- printf >&2 'bl: Non-negative line count needed as sole argument\n'
- exit 2
-fi
-n=0
-while [ "$n" -lt "${1:-0}" ] ; do
- printf '\n'
- n=$((n+1))
-done
diff --git a/bin/clog.sh b/bin/clog.sh
index 1b612d68..3269c508 100644
--- a/bin/clog.sh
+++ b/bin/clog.sh
@@ -1,17 +1,17 @@
# Record a timestamped message to a logfile, defaulting to ~/.clog
-self=clog
-# Ignore arguments
-set --
+# Build the cat(1) command we'll run, wrapping it in rlwrap(1) if available and
+# applicable.
+if [ "$#" -eq 0 ] && [ -t 0 ] && command -v rlwrap >/dev/null 2>&1 ; then
+ set -- rlwrap --history-filename=/dev/null cat -- "${@:--}"
+else
+ set -- cat -- "${@:--}"
+fi
-# If we have rlwrap, quietly use it
-command -v rlwrap >/dev/null 2>&1 &&
- set -- rlwrap --history-filename=/dev/null -C "$self" "$@"
-
-# Write the date, the standard input (rlwrapped if applicable), and two dashes
-# to $CLOG, defaulting to ~/.clog.
+# Write the date, the input, and two dashes to $CLOG, defaulting to ~/.clog.
+clog=${CLOG:-"$HOME"/.clog}
{
date
- "$@" cat -
- printf '%s\n' --
-} >>"${CLOG:-"$HOME"/.clog}"
+ "$@"
+ printf -- '--\n'
+} >> "$clog"
diff --git a/bin/sra.sh b/bin/sra.sh
index f3ed6f71..36a673e1 100644
--- a/bin/sra.sh
+++ b/bin/sra.sh
@@ -3,5 +3,6 @@
exec 3<&0
sls | while read -r hostname ; do
printf 'sra: %s\n' "$hostname"
- ssh -qt -- "$hostname" "$@" <&3 # shellcheck disable=SC2029
+ # shellcheck disable=SC2029
+ ssh -qt -- "$hostname" "$@" <&3
done
diff --git a/bin/sshi.sh b/bin/sshi.sh
index 0d1591f1..4872765d 100644
--- a/bin/sshi.sh
+++ b/bin/sshi.sh
@@ -20,7 +20,7 @@ printf '%s\n' "$SSH_CONNECTION" "${SSH_TTY:-unknown}" |
sh=$(dig -x "$si" +short 2>/dev/null | sed 's/\.$//;1q')
# Print the results in a human-readable format
- printf "%s:%u -> %s:%u (%s)\n" \
+ printf '%s:%u -> %s:%u (%s)\n' \
"${ch:-"$ci"}" "$cp" \
"${sh:-"$si"}" "$sp" \
"$tty"
diff --git a/man/man1/ax.1df b/man/man1/ax.1df
index b3218d37..40125167 100644
--- a/man/man1/ax.1df
+++ b/man/man1/ax.1df
@@ -1,15 +1,21 @@
-.TH AX 1df "July 2016" "Manual page for ax"
+.TH AX 1df "January 2018" "Manual page for ax"
.SH NAME
.B ax
\- evaluate an awk expression
.SH SYNOPSIS
-.B ax '2.0+3.0'
+.B ax
+\&'2.0+3.0'
.br
-.B ax %.2f 'sin(2)'
+.B ax
+\&'%.2f\\n' 'sin(2)'
.SH DESCRIPTION
.B ax
evaluates an expression given on the command line with awk(1) and prints its
result using awk's printf, with an optional format specified preceding the
expression.
+.SH SECURITY
+Note that the second argument has no evaluation protection on it. There's very
+little to stop a user putting a fully-fledged awk program in as the second
+argument if they needed to. Don't accept untrusted user input in this argument!
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/clog.1df b/man/man1/clog.1df
index 43193076..f9300347 100644
--- a/man/man1/clog.1df
+++ b/man/man1/clog.1df
@@ -3,18 +3,28 @@
.B clog
\- record timestamped logs in a file
.SH SYNOPSIS
+$
.B clog
.br
-getting real tired of all this overengineering
+Getting real tired of all this overengineering.
.br
^D
+.br
+$
+.B clog
+file1 file2
+.br
+$
+command |
+.B clog
.SH DESCRIPTION
.B clog
-receives a message on stdin, timestamps it with a leading date(1), and writes
-it to the file with path in environment variable CLOG, defaulting to ~/.clog,
-terminating each entry with two hyphens.
+receives a message on stdin or from the file arguments, timestamps it with a
+leading date(1), and writes it to the file with path in environment variable
+CLOG, defaulting to ~/.clog, terminating each entry with two hyphens.
.P
-If rlwrap(1) is found, it will be used for the line editing. If not, just the
+If there are no files to read and standard input is coming from a terminal, and
+rlwrap(1) is found, it will be used for the line editing. If not, just the
terminal's cooked mode will be used.
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh
index debb93b6..d8d13e0a 100644
--- a/sh/profile.d/editor.sh
+++ b/sh/profile.d/editor.sh
@@ -1,7 +1,7 @@
# Ideally, we'd use plain old ed(1), but many Linux distributions don't install
# it by default
if command -v ed >/dev/null 2>&1 ; then
- EDITOR=ed
+ EDITOR='ed'
# Failing that, if the system's implementation of ex(1) looks like Vim and we
# have exm(1df) in our $PATH, use the latter to work around Vim's ex mode
@@ -15,11 +15,11 @@ elif (
(*) exit 1 ;;
esac
) >/dev/null 2>&1 ; then
- EDITOR=exm
+ EDITOR='exm'
# Otherwise, we can just call ex(1) directly
else
- EDITOR=ex
+ EDITOR='ex'
fi
export EDITOR
diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh
index 38ab9893..119d81c7 100644
--- a/sh/profile.d/visual.sh
+++ b/sh/profile.d/visual.sh
@@ -1,3 +1,3 @@
# Use first found implementation of vi(1)
-VISUAL=vi
+VISUAL='vi'
export VISUAL
diff --git a/sh/shrc.d/tree.sh b/sh/shrc.d/tree.sh
index ca134fe2..d462f3e1 100644
--- a/sh/shrc.d/tree.sh
+++ b/sh/shrc.d/tree.sh
@@ -12,6 +12,7 @@ tree() {
case $opt in
n) n=1 ;;
C) C=1 ;;
+ *) ;;
esac
done
[ -z "$C" ] || exit 0
diff --git a/vim/doc/copy_linebreak.txt b/vim/doc/copy_linebreak.txt
index 7efbad4b..581c6166 100644
--- a/vim/doc/copy_linebreak.txt
+++ b/vim/doc/copy_linebreak.txt
@@ -26,11 +26,11 @@ There are no default key mappings to any of these targers; you should define
them yourself in your |vimrc|. For example:
>
:nmap <Leader>b <Plug>CopyLinebreakToggle
-
+<
COMMANDS *copy_linebreak-commands*
If the |+user_commands| feature is available, commands provided are:
->
+
`:CopyLinebreakEnable`: *:CopyLinebreakEnable*
Enable copy-paste friendly line break options.
`:CopyLinebreakDisable`: *:CopyLinebreakDisable*
diff --git a/vim/doc/mail_mutt.txt b/vim/doc/mail_mutt.txt
index c3f8afaa..1129651d 100644
--- a/vim/doc/mail_mutt.txt
+++ b/vim/doc/mail_mutt.txt
@@ -23,7 +23,7 @@ agent, as the initial content of a new message.
:.MailMutt
:3,6MailMutt
:95,$MailMutt
-
+<
MAPPINGS *mail_mutt-mappings*
Three <Plug> mapping targets are also provided for convenience. No attempt is
diff --git a/vim/doc/strip_trailing_whitespace.txt b/vim/doc/strip_trailing_whitespace.txt
index 9e2907d4..2b220231 100644
--- a/vim/doc/strip_trailing_whitespace.txt
+++ b/vim/doc/strip_trailing_whitespace.txt
@@ -27,7 +27,7 @@ mappable in any mode. There is no default key mapping to the target; you
should define this yourself in your |vimrc|. For example:
>
:nmap <Leader>x <Plug>StripTrailingWhitespace>
-
+<
AUTHOR *strip_trailing_whitespace-author*
Written and maintained by Tom Ryder <tom@sanctum.geek.nz>.