diff --git a/bin/ZZZ.sh b/bin/ZZZ.sh
index fe88ec6..d1909a5 100644
--- a/bin/ZZZ.sh
+++ b/bin/ZZZ.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# ZZZ
-# Written in 2019 by Lucas
+# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -12,7 +12,7 @@
doas true || exit $?
-printf "Hibernating in";
+printf "Hibernating in"
for i in 3 2 1; do
printf " %d..." $i
sleep 1
diff --git a/bin/credentials.sh b/bin/credentials.sh
index 1776c42..dca561e 100644
--- a/bin/credentials.sh
+++ b/bin/credentials.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# credentials
-# Written in 2019 by Lucas
+# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -63,25 +63,25 @@ get_service()
if [ $user = no ] && [ $pass = no ] && [ $sfa = no ]; then
sekrit has "services/$service/pass" ||
- err "Unknown service \"$service\"."
+ err "unknown service $service"
pass=yes
- sekrit has services/"$service"/user && user=yes
- sekrit has services/"$service"/2fa && sfa=yes
+ sekrit has "services/$service/user" && user=yes
+ sekrit has "services/$service/2fa" && sfa=yes
fi
if [ $user = check ]; then
- sekrit has services/"$service"/user ||
- err "Service \"$service\" has no user."
+ sekrit has "services/$service/user" ||
+ err "service $service has no user"
user=yes
fi
if [ $pass = check ]; then
- sekrit has services/"$service"/pass ||
- err "Service \"$service\" has no pass."
+ sekrit has "services/$service/pass" ||
+ err "service $service has no pass"
pass=yes
fi
if [ $sfa = check ]; then
- sekrit has services/"$service"/2fa ||
- err "Service \"$service\" has no 2fa."
+ sekrit has "services/$service/2fa" ||
+ err "service $service has no 2fa"
sfa=yes
fi
@@ -94,7 +94,7 @@ get_raw()
{
key=$1
- sekrit has "$key" || err "Unknown key \"$key\"."
+ sekrit has "$key" || err "unknown key $key"
printf "%s" "$key"
sekrit get "$key" | clip && printf "\n"
@@ -118,14 +118,14 @@ while getopts 2pru flag; do
;;
esac
done
-shift $(($OPTIND - 1))
+shift $((OPTIND - 1))
[ $# -eq 1 ] && [ -n "$1" ] || usage
key=$1
if [ $raw = yes ]; then
if [ $sfa != no ] || [ $pass != no ] || [ $user != no ]; then
- err "-r is mutually exclusive with -2pu."
+ err "-r is mutually exclusive with -2pu"
fi
get_raw "$key"
else
diff --git a/bin/fetch.sh b/bin/fetch.sh
index 5f3c159..b65bded 100644
--- a/bin/fetch.sh
+++ b/bin/fetch.sh
@@ -39,14 +39,14 @@ while getopts T flag; do
;;
esac
done
-shift $(($OPTIND - 1))
+shift $((OPTIND - 1))
[ $# -gt 0 ] || usage
: ${ARCHIVE_BASEDIR:=~/tmp/archive}
mkdir -p "$ARCHIVE_BASEDIR"
everything=$ARCHIVE_BASEDIR/everything
-test -f "$everything" || touch "$everything"
+touch "$everything"
dir=$ARCHIVE_BASEDIR/$(date +%Y/%m/%d)
mkdir -p "$dir" || exit 1
@@ -57,7 +57,7 @@ for url; do
outdir=$dir/$sha
if grep -q "^$url\$" "$everything"; then
- printf "%s: \"%s\" already fetched.\n" "${0##*/}" "$url" >&2
+ printf "%s: already fetched %s\n" "${0##*/}" "$url" >&2
printf "%s/file\n" "$(find_dir "$sha")"
continue
fi
diff --git a/bin/imgresize.sh b/bin/imgresize.sh
index 245ac49..bf3dc46 100644
--- a/bin/imgresize.sh
+++ b/bin/imgresize.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# imgresize
-# Written in 2019 by Lucas
+# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -29,13 +29,12 @@ err()
check_dimension_format()
{
- printf "%s\n" "$1" | grep -q "^[0-9]*x[0-9]*\$" \
- && [ "$1" != "x" ]
+ printf "%s\n" "$1" | grep -q "^[0-9]*x[0-9]*\$" && [ "$1" != "x" ]
}
[ $# -eq 3 ] && check_dimension_format "$1" || usage
-[ -n "$2" ] || err "Input file name can't be empty."
-[ -n "$3" ] || err "Output file name can't be empty."
+[ -n "$2" ] || err "input file name can't be empty"
+[ -n "$3" ] || err "output file name can't be empty"
size=$1
w=${size%x*}
@@ -50,7 +49,7 @@ case $infile in
;;
*.png) inprog=pngtopam
;;
-*) err "Unknown input format."
+*) err "unknown input format"
;;
esac
@@ -61,10 +60,10 @@ case $outfile in
;;
*.png) outprog=pamtopng
;;
-*) err "Unknown output format."
+*) err "unknown output format"
;;
esac
-"$inprog" <"$infile" \
- | pamscale ${w:+-width "$w"} ${h:+-height "$h"} \
- | "$outprog" >"$outfile"
+$inprog <"$infile" |
+ pamscale ${w:+-width "$w"} ${h:+-height "$h"} |
+ $outprog >"$outfile"
diff --git a/bin/invidious.sh b/bin/invidious.sh
index 3a64e00..ccabf67 100644
--- a/bin/invidious.sh
+++ b/bin/invidious.sh
@@ -88,10 +88,10 @@ shift $((OPTIND - 1))
[ $# -eq 1 ] || usage
url=$1
-known_site "$url" || err "Unknown site: $url"
+known_site "$url" || err "unknown site $url"
id=$(get_id "$url")
-[ ${#id} -eq 11 ] || err "invalid video ID"
+[ ${#id} -eq 11 ] || err "invalid video ID $id"
# XXX choose in some clever way
itag=$(torsocks ftp -MVo - "$(api "/api/v1/videos/$id")" |
diff --git a/bin/plumb.sh b/bin/plumb.sh
index 8ce6b1b..1e7d7a9 100644
--- a/bin/plumb.sh
+++ b/bin/plumb.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# o
+# plumb
# Written in 2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
diff --git a/bin/pstsrv.sh b/bin/pstsrv.sh
index 56e73e7..ea0a6d8 100644
--- a/bin/pstsrv.sh
+++ b/bin/pstsrv.sh
@@ -25,7 +25,7 @@ err()
check_prog()
{
if ! command -v "$1" >/dev/null 2>&1; then
- printf "%s: Missing required program \"%s\"\n" \
+ printf "%s: missing required program %s\n" \
"${0##*/}" "$1" >&2
return 1
fi
@@ -95,6 +95,6 @@ ix.io)
do_upload pst_ix_io "$@"
;;
*)
- err "Unknown service \"$srv\""
+ err "unknown service $srv"
;;
esac
diff --git a/bin/rfcopen.sh b/bin/rfcopen.sh
index e3bc310..4ebc4ee 100644
--- a/bin/rfcopen.sh
+++ b/bin/rfcopen.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# rfcopen
-# Written in 2019 by Lucas
+# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -38,7 +38,7 @@ while getopts T flag; do
;;
esac
done
-shift $(($OPTIND - 1))
+shift $((OPTIND - 1))
[ $# -eq 1 ] && [ -n "$1" ] && n=$(tonumber "$1") || usage
rfcfile=$RFCDIR/rfc$n.txt
@@ -46,7 +46,6 @@ url=https://tools.ietf.org/rfc/rfc$n.txt
mkdir -p "$RFCDIR"
if [ ! -f "$rfcfile" ]; then
- $torsocks ftp -Vo "$rfcfile" "$url" || err "Couldn't fetch RFC $n."
+ $torsocks ftp -Vo "$rfcfile" "$url" || err "couldn't fetch RFC $n"
fi
-
${PAGER:-more} "$rfcfile"
diff --git a/bin/screenshot.sh b/bin/screenshot.sh
index b106a69..2ae8ef1 100644
--- a/bin/screenshot.sh
+++ b/bin/screenshot.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# screenshot
-# Written in 2019 by Lucas
+# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -31,14 +31,16 @@ err()
case $# in
0) set -- -root
;;
-1) [ "$1" = "-window" ] || err "Unknown option \"$1\"."
+1) [ "$1" = "-window" ] || err "unknown option $1"
set --
;;
-2) [ "$1" = "-id" ] || [ "$1" = "-name" ] || err "Unknown option \"$1\"."
- [ -n "$2" ] || err "$1 expects a non-empty parameter."
+2) [ "$1" = "-id" ] || [ "$1" = "-name" ] || err "unknown option $1"
+ [ -n "$2" ] || err "$1 expects a non-empty parameter"
;;
*) usage
;;
esac
-xwd -silent "$@" | xwdtopnm | pnmtopng >~/media/ss/"$(date +%Y%m%d-%H%M%S)".png
+: ${SCREENSHOTS:=~/media/ss}
+xwd -silent "$@" | xwdtopnm |
+ pnmtopng >"$SCREENSHOTS/$(date +%Y%m%d-%H%M%S).png"
diff --git a/bin/sekrit.sh b/bin/sekrit.sh
index 98d65bd..373b07c 100644
--- a/bin/sekrit.sh
+++ b/bin/sekrit.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# sekrit
-# Written in 2018-2019 by Lucas
+# Written in 2018-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -50,7 +50,7 @@ check_key()
{
case $1 in
*/ | /* | ./* | */./* | */. | ../* | */../* | */..)
- err "Key can not end in a slash."
+ err "$1: invalid key"
;;
esac
}
@@ -70,9 +70,10 @@ sekrit_add()
f=$SEKRIT_DIR/$key.gpg
mkdir -p "${f%/*}"
- [ -f "$f" ] && err "Key \"$key\" already exists."
+ [ -f "$f" ] && err "key $key already exists"
if [ $# -gt 0 ]; then
+ # use all additional parameters as a single string
printf "%s\n" "$*"
else
cat -
@@ -88,13 +89,13 @@ sekrit_gen()
while getopts l: flag; do
case "$flag" in
l) len=$(to_number "$OPTARG") ||
- err "Invalid password length."
+ err "invalid password length"
;;
*) usage
;;
esac
done
- shift $(($OPTIND - 1))
+ shift $((OPTIND - 1))
[ $# -le 1 ] || usage
@@ -116,7 +117,7 @@ sekrit_get()
shift
f=$SEKRIT_DIR/$key.gpg
- [ -f "$f" ] || err "No data for key \"$key\"."
+ [ -f "$f" ] || err "no data for key $key"
gpg2 -qd "$f"
}
diff --git a/utils/bg/generate-FreeHugsBSD.sh b/utils/bg/generate-FreeHugsBSD.sh
index 9e43925..08f60d4 100644
--- a/utils/bg/generate-FreeHugsBSD.sh
+++ b/utils/bg/generate-FreeHugsBSD.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# env
-# Written in 2019 by Lucas
+# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -16,19 +16,18 @@
: ${IMAGE_HEIGHT:=500}
: ${IMAGE_WIDTH:=500}
-pos_x=$((3 * $CANVAS_WIDTH / 4 - $IMAGE_WIDTH / 2))
-pos_y=$(($CANVAS_HEIGHT / 2 - $IMAGE_HEIGHT / 2))
+pos_x=$((3 * CANVAS_WIDTH / 4 - IMAGE_WIDTH / 2))
+pos_y=$((CANVAS_HEIGHT / 2 - IMAGE_HEIGHT / 2))
if ! tmpfile=$(mktemp -t bg.XXXXXXXXXX); then
- printf "%s: Can't create temporary file.\n" "${0##*/}" >&2
+ printf "%s: can't create temporary file\n" "${0##*/}" >&2
exit 1
fi
trap 'rm -f "$tmpfile"' EXIT INT QUIT TERM
-pngtopam -alphapam FreeHugsBSD.png \
- | pamscale -width="$IMAGE_WIDTH" -height="$IMAGE_HEIGHT" \
- >"$tmpfile"
-ppmmake "$CANVAS_BGCOLOR" "$CANVAS_WIDTH" "$CANVAS_HEIGHT" \
- | pamcomp -xoff="$pos_x" -yoff="$pos_y" "$tmpfile" \
- | pamtopng >FreeHugsBSD-bg.png
+pngtopam -alphapam FreeHugsBSD.png |
+ pamscale -width "$IMAGE_WIDTH" -height "$IMAGE_HEIGHT" >"$tmpfile"
+ppmmake "$CANVAS_BGCOLOR" "$CANVAS_WIDTH" "$CANVAS_HEIGHT" |
+ pamcomp -xoff "$pos_x" -yoff "$pos_y" "$tmpfile" |
+ pamtopng >FreeHugsBSD-bg.png
diff --git a/utils/bg/generate-cyberia.sh b/utils/bg/generate-cyberia.sh
index cc33bc4..b76d580 100644
--- a/utils/bg/generate-cyberia.sh
+++ b/utils/bg/generate-cyberia.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# env
-# Written in 2019 by Lucas
+# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -16,19 +16,18 @@
: ${IMAGE_HEIGHT:=768}
: ${IMAGE_WIDTH:=1080}
-pos_x=$((($CANVAS_WIDTH - $IMAGE_WIDTH) / 2))
-pos_y=$((($CANVAS_HEIGHT - $IMAGE_HEIGHT) / 2))
+pos_x=$(((CANVAS_WIDTH - IMAGE_WIDTH) / 2))
+pos_y=$(((CANVAS_HEIGHT - IMAGE_HEIGHT) / 2))
if ! tmpfile=$(mktemp -t bg.XXXXXXXXXX); then
- printf "%s: Can't create temporary file.\n" "${0##*/}" >&2
+ printf "%s: can't create temporary file\n" "${0##*/}" >&2
exit 1
fi
trap 'rm -f "$tmpfile"' EXIT INT QUIT TERM
-pngtopam -alphapam cyberia-cafe-club.png \
- | pamscale -width="$IMAGE_WIDTH" -height="$IMAGE_HEIGHT" \
- >"$tmpfile"
-ppmmake "$CANVAS_BGCOLOR" "$CANVAS_WIDTH" "$CANVAS_HEIGHT" \
- | pamcomp -xoff="$pos_x" -yoff="$pos_y" "$tmpfile" \
- | pamtopng >cyberia-cafe-club-bg.png
+pngtopam -alphapam cyberia-cafe-club.png |
+ pamscale -width "$IMAGE_WIDTH" -height "$IMAGE_HEIGHT" >"$tmpfile"
+ppmmake "$CANVAS_BGCOLOR" "$CANVAS_WIDTH" "$CANVAS_HEIGHT" |
+ pamcomp -xoff "$pos_x" -yoff "$pos_y" "$tmpfile" |
+ pamtopng >cyberia-cafe-club-bg.png
diff --git a/utils/scripts/gen-ec-cert.sh b/utils/scripts/gen-ec-cert.sh
index ee9ce7e..77115d7 100644
--- a/utils/scripts/gen-ec-cert.sh
+++ b/utils/scripts/gen-ec-cert.sh
@@ -1,4 +1,15 @@
#!/bin/sh
+# env
+# Written in 2020 by Lucas
+# CC0 1.0 Universal/Public domain - No rights reserved
+#
+# To the extent possible under law, the author(s) have dedicated all
+# copyright and related and neighboring rights to this software to the
+# public domain worldwide. This software is distributed without any
+# warranty. You should have received a copy of the CC0 Public Domain
+# Dedication along with this software. If not, see
+# .
+
usage()
{
printf "Usage: %s [-c curve] [-d days] domain\n" "${0##*/}" >&2
@@ -28,7 +39,7 @@ shift $((OPTIND - 1))
domain=$1
if [ -f "$domain.key" ]; then
- printf "%s: key for %s already exists; reusing it.\n" \
+ printf "%s: key for %s already exists; reusing it\n" \
"${0##*/}" "$domain" >&2
else
(umask 0377 &&
diff --git a/utils/scripts/sekrit-rekey.sh b/utils/scripts/sekrit-rekey.sh
index 906614d..a158453 100644
--- a/utils/scripts/sekrit-rekey.sh
+++ b/utils/scripts/sekrit-rekey.sh
@@ -1,4 +1,15 @@
#!/bin/sh
+# env
+# Written in 2020 by Lucas
+# CC0 1.0 Universal/Public domain - No rights reserved
+#
+# To the extent possible under law, the author(s) have dedicated all
+# copyright and related and neighboring rights to this software to the
+# public domain worldwide. This software is distributed without any
+# warranty. You should have received a copy of the CC0 Public Domain
+# Dedication along with this software. If not, see
+# .
+
usage()
{
printf "Usage: %s newkey\n" "${0##*/}" >&2
@@ -18,21 +29,21 @@ newsekrit()
[ $# -eq 1 ] || usage
newkey=$1
-gpg2 -k "$newkey" >/dev/null || err "Can't find key \"$newkey\""
+gpg2 -k "$newkey" >/dev/null || err "can't find key $newkey"
umask 077
newdir=$(mktemp -dt sekrit-XXXXXXXXXX) ||
- err "Failed to create temporary directory"
+ err "failed to create temporary directory"
scratch=$(mktemp -tp "$newdir" .sekrit-scratch-XXXXXXXXXX) ||
- err "Failed to create scratch file"
+ err "failed to create scratch file"
trap 'rm -fr -- "$scratch" "$newdir"' INT QUIT TERM
for entry in $(sekrit ls | grep -v ^DONE); do
printf "%s... " "$entry"
sekrit get "$entry" >|"$scratch" ||
- err "Failed to export entry \"$entry\""
+ err "failed to export entry $entry"
newsekrit add "$entry" <"$scratch" ||
- err "Failed to import entry \"$entry\""
+ err "failed to import entry $entry"
printf "OK\n"
done
rm -f "$scratch"
diff --git a/utils/scripts/termcolors.sh b/utils/scripts/termcolors.sh
index 1f248a8..c0eb775 100644
--- a/utils/scripts/termcolors.sh
+++ b/utils/scripts/termcolors.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# env
-# Written in 2019 by Lucas
+# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@@ -22,7 +22,7 @@ tput rev
printf " bg on fg "
tput sgr0
for i in 0 1 2 3 4 5 6 7; do
- tput setab $(($i + 8)) 0 0
+ tput setab $((i + 8)) 0 0
printf " "
done
printf "\n"
diff --git a/utils/scripts/update-riot-web.sh b/utils/scripts/update-riot-web.sh
index 49aa1de..1e5648d 100644
--- a/utils/scripts/update-riot-web.sh
+++ b/utils/scripts/update-riot-web.sh
@@ -1,4 +1,15 @@
#!/bin/sh
+# env
+# Written in 2020 by Lucas
+# CC0 1.0 Universal/Public domain - No rights reserved
+#
+# To the extent possible under law, the author(s) have dedicated all
+# copyright and related and neighboring rights to this software to the
+# public domain worldwide. This software is distributed without any
+# warranty. You should have received a copy of the CC0 Public Domain
+# Dedication along with this software. If not, see
+# .
+
usage()
{
printf "Usage: %s version\n" "${0##*/}" >&2
@@ -16,19 +27,14 @@ isversion()
printf "%s\n" "$*" | grep -Eq "^v[0-9]+\.[0-9]+\.[0-9]+$"
}
-if [ -z "${RIOT_WEB_UI_DIR:-}" ]; then
- err "Environment RIOT_WEB_UI_DIR unset"
-fi
-
-if [ $# -ne 1 ] || ! isversion "$1"; then
- usage
-fi
+[ -n "${RIOT_WEB_UI_DIR:-}" ] || err "environment var RIOT_WEB_UI_DIR unset"
+[ $# -eq 1 ] && isversion "$1" || usage
ver=$1
GH_BASE_URL=https://github.com/vector-im/riot-web/releases/download
-cd "$RIOT_WEB_UI_DIR" || err "Can't cd to web UI directory"
+cd "$RIOT_WEB_UI_DIR" || err "can't cd to web UI directory"
ftp -o - "$GH_BASE_URL/$ver/riot-$ver.tar.gz" | pax -rz ||
- err "Can't fetch and extract release"
+ err "can't fetch and extract release"
rm -f riot && ln -s "riot-$ver" riot ||
- err "Can't point web UI directory to new release"
+ err "can't point web UI directory to new release"