M archives/tarcat => archives/tarcat +2 -2
@@ 35,7 35,7 @@ while [[ $# -gt 0 ]]; do
;;
-p|--passphrase)
- passphrase="--passphrase $2"
+ passphrase="$2"
shift; shift
;;
@@ 60,7 60,7 @@ done
code=0
for archive_fn in "${positional[@]}"; do
archive_action="$(archive_extension "$archive_fn" | tee >(>&2 /usr/bin/head -n -1) | /usr/bin/tail -n 1)"
- if ! unarchive --archive=$archive_action --stdout "$archive_fn" $passphrase; then
+ if ! unarchive --archive=$archive_action --stdout "$archive_fn" ${passphrase:+--passphrase "$passphrase"}; then
code=1
fi
done
M archives/tarls => archives/tarls +2 -2
@@ 35,7 35,7 @@ while [[ $# -gt 0 ]]; do
;;
-p|--passphrase)
- passphrase="--passphrase $2"
+ passphrase="$2"
shift; shift
;;
@@ 60,7 60,7 @@ done
code=0
for archive_fn in "${positional[@]}"; do
archive_action="$(archive_extension "$archive_fn" | tee >(>&2 /usr/bin/head -n -1) | /usr/bin/tail -n 1)"
- if ! unarchive --archive=$archive_action --list "$archive_fn" $passphrase; then
+ if ! unarchive --archive=$archive_action --list "$archive_fn" ${passphrase:+--passphrase "$passphrase"}; then
code=1
fi
done
M archives/unarchive.bash => archives/unarchive.bash +3 -1
@@ 358,7 358,9 @@ unarchive() {
;;
*)
- archive_fn="$(realpath "$1")"
+ if [[ ! -z "$1" ]]; then
+ archive_fn="$(realpath "$1")"
+ fi
shift
;;
esac
M archives/untar => archives/untar +3 -3
@@ 27,7 27,7 @@ while [[ $# -gt 0 ]]; do
-d|--to-directory)
debug_msg "Setting to_directory option to '${2}' (was ${to_directory})"
- to_directory="--directory $2"
+ to_directory="$2"
shift; shift
;;
@@ 44,7 44,7 @@ while [[ $# -gt 0 ]]; do
-p|--passphrase)
debug_msg "Setting passphrase option to '${2}' (was ${passphrase})"
- passphrase="--passphrase $2"
+ passphrase="$2"
shift; shift
;;
@@ 69,7 69,7 @@ done
code=0
for archive_fn in "${positional[@]}"; do
archive_action="$(archive_extension "$archive_fn" | tee >(>&2 /usr/bin/head -n -1) | /usr/bin/tail -n 1)"
- if ! unarchive --archive=$archive_action "$archive_fn" $passphrase $to_directory; then
+ if ! unarchive --archive=$archive_action "$archive_fn" ${passphrase:+--passphrase "$passphrase"} ${to_directory:+--directory "$to_directory"}; then
code=1
fi
done
A core/shebangs => core/shebangs +43 -0
@@ 0,0 1,43 @@
+#!/bin/sh
+
+name="shebangs"
+version="1.0"
+usage_message="Usage: shebangs [PATH]"
+help_message=$(/usr/bin/cat <<-EOF
+ Print the shebang line of each executable script
+ Usage: shebangs [PATH]
+ Options:
+ -h, --help print this message and exit
+ -v, --version print version number and exit
+EOF
+)
+
+. /usr/local/lib/myminiparse.sh
+
+# loop through arguments
+dir=
+for arg; do
+ case "$arg" in
+ -q|--quiet)
+ #ignore these
+ ;;
+
+ *)
+ if [ -z "$dir" ]; then
+ dir="$arg"
+ fi
+ ;;
+ esac
+done
+
+if [ -z "$dir" ]; then
+ dir="."
+fi
+
+/usr/bin/find "$dir" -maxdepth 1 -type f -printf "%f\0" \
+ | /usr/bin/sort -z \
+ | while IFS= read -r -d '' fn; do
+ /usr/bin/printf '%s:' "$fn"
+ /usr/bin/head --lines=1 "$fn"
+done | grep --regexp=':#!' | column --separator ':' --table
+
M documents/hugo-post => documents/hugo-post +9 -3
@@ 39,12 39,18 @@ fi
# check if title can be made into a new filename
filename="$(/usr/bin/printf "$title" | /usr/bin/tr --squeeze-repeat ' ' '_' | /usr/bin/tr --complement --delete '[:alnum:]_-').md"
-if [ -f "$filename" ]; then
+path="content/posts/${filename}"
+if [ ! -d "content" ] || [ ! -d "content/posts" ]; then
+ if [ "$quiet" -eq 0 ]; then
+ (>&2 /usr/bin/printf "%s: not in a Hugo directory\n" "$name")
+ fi
+ exit 1
+elif [ -f "$path" ]; then
if [ "$quiet" -eq 0 ]; then
(>&2 /usr/bin/printf "%s: '%s' already exists\n" "$name" "$filename")
fi
exit 1
-elif [ -d "$filename" ]; then
+elif [ -d "$path" ]; then
if [ "$quiet" -eq 0 ]; then
(>&2 /usr/bin/printf "%s: '%s' is a directory\n" "$name" "$filename")
fi
@@ 52,5 58,5 @@ elif [ -d "$filename" ]; then
fi
# create new file
-/usr/bin/printf -- '---\ntitle: %s\ndate: %s\n---\n\n' "$title" "$(hugo-date)" >"$filename"
+/usr/bin/printf -- '---\ntitle: %s\ndate: %s\ndraft: true\n---\n\n' "$title" "$(hugo-date)" > "$path"