commit a0ebd41326feaf9c1f1b30e1392f2b9cf4504465
parent 9384fc4b6422db590679fa9f9e9a230fdb3a3ca2
Author: parazyd <parazyd@dyne.org>
Date: Thu, 5 Jul 2018 02:22:41 +0200
Apply shell script linting.
Performed using shellcheck.
Diffstat:
8 files changed, 56 insertions(+), 54 deletions(-)
diff --git a/bin/rpabook b/bin/rpabook
@@ -9,13 +9,13 @@ profile="${RPPROFILE:-$HOME/.rp/default}"
ab="$profile/whitelist.abook"
usage() {
- printf " * usage: $(basename $0) [-a < email] [-c pattern]\n"
- printf "\t-a: add to abook\n"
- printf "\t-c: completion (used from mutt)\n"
+ printf " * usage: %s [-a < email] [-c pattern]\\n" "$(basename "$0")"
+ printf "\\t-a: add to abook\\n"
+ printf "\\t-c: completion (used from mutt)\\n"
exit 1
}
-for i in $@; do
+for i in "$@"; do
case "$i" in
-a)
email="$(cat)"
diff --git a/bin/rpcomp b/bin/rpcomp
@@ -10,10 +10,10 @@ to=""
[ $# -gt 0 ] && to="$1"
[ $# -gt 1 ] && {
shift 1
- for i in $@; do
+ for i in "$@"; do
ccs="${ccs}${i}, "
done
- ccs="$(echo $ccs | rev | cut -c2- | rev)"
+ ccs="$(echo "$ccs" | rev | cut -c3- | rev)"
}
printf "Date: %s
@@ -25,17 +25,17 @@ Bcc:
Message-ID: %s
User-Agent: rp
MIME-Version: 1.0
-Content-Type: text/plain; charset=\"utf-8\"\n" \
+Content-Type: text/plain; charset=\"utf-8\"
+
+
+Text\\n\\n" \
"$(LANG=C date "+%a, %d %b %Y %T %Z")" \
- "$(rpheaders defaultfrom < $profile/config)" \
+ "$(rpheaders defaultfrom < "$profile"/config)" \
"$to" \
"$ccs" \
- "$(rputil -e genmsgid)" \
- "$content_head"
-
-printf "\n\nText\n\n"
+ "$(rputil -e genmsgid)"
[ -e "$HOME/.signature" ] && {
- printf -- "-- \n"
+ printf -- "-- \\n"
cat "$HOME/.signature"
}
diff --git a/bin/rpgenc b/bin/rpgenc
@@ -14,16 +14,16 @@ else
to="-r $(echo "$email" | rpheaders To | awk -F'<' '{print $NF}' | tr -d '><')"
fi
-headers="$(printf "$email" | \
+headers="$(echo "$email" | \
sed '/^$/q' | \
sed '/^\r/q' | \
sed "/Content-Type: /d" | \
sed "/^ /d" | \
head -n-1)"
-emabody="$(printf "$email" | sed '1,/^$/d' )"
+emabody="$(echo "$email" | sed '1,/^$/d' )"
[ -n "$emabody" ] || \
-emabody="$(printf "$email" | sed '1,/^\r/d' )"
+emabody="$(echo "$email" | sed '1,/^\r/d' )"
encr="$(echo "$emabody" | sed 's/$/\r/' | gpg -eaq --batch "$to" -)"
diff --git a/bin/rpgsign b/bin/rpgsign
@@ -29,7 +29,7 @@ signature="$(echo "$tosign" | sed 's/$/\r/' | gpg -baq --batch)"
# We need a newline to conform with rfc3156
# TODO; remove -e flag and make detection automagic.
-[ -n "$enc" ] && headers="$headers\n"
+[ -n "$enc" ] && headers="$headers\\n"
cat <<EOM
$headers
diff --git a/bin/rpinit b/bin/rpinit
@@ -10,21 +10,21 @@ setupmutt() {
echo " * copying mutt files"
mkdir -p "$HOME/.rp/$1/mutt"
touch "$HOME/.rp/$1/mutt/muttpass"
- for i in $(ls -1 $shareprefix/mutt); do
+ for i in "$shareprefix"/mutt/*; do
cp -f "$shareprefix/mutt/$i" "$HOME/.rp/$1/mutt/"
done
}
usage() {
- printf " * usage: $(basename $0) [-u profilename]\n"
- printf "\t-u: update\n"
+ printf " * usage: %s [-u profilename]\\n" "$(basename "$0")"
+ printf "\\t-u: update\\n"
exit 1
}
[ -n "$1" ] && {
case "$1" in
-u)
- [ -n "$2" ] || prof="$(readlink $HOME/.rp/default)"
+ [ -n "$2" ] || prof="$(readlink "$HOME"/.rp/default)"
setupmutt "$prof"
exit 0
;;
@@ -103,9 +103,9 @@ read -r lpass || exit 1
echo
-lproto="$(echo $lnet | cut -d'!' -f1)"
-lserv="$(echo $lnet | cut -d'!' -f2)"
-lport="$(echo $lnet | cut -d'!' -f3)"
+lproto="$(echo "$lnet" | cut -d'!' -f1)"
+lserv="$(echo "$lnet" | cut -d'!' -f2)"
+lport="$(echo "$lnet" | cut -d'!' -f3)"
case "$lproto" in
tcp)
@@ -121,7 +121,7 @@ case "$lport" in
lport=993;;
esac
-cat <<EOF > $profile/muttrc
+cat <<EOF > "$profile"/muttrc
# muttrc for $profile
source ~/.rp/$profile/mutt/general
source ~/.rp/$profile/mutt/headers
@@ -132,7 +132,7 @@ source ~/.rp/$profile/mutt/gpg
source ~/.rp/$profile/mutt/muttpass
set from = "$from"
-set realname = "$(echo $from | cut -d'<' -f1)"
+set realname = "$(echo "$from" | cut -d'<' -f1)"
set folder = "${lproto}://${luser}@${lserv}:${lport}"
set spoolfile = "${lproto}://${luser}@${lserv}:${lport}/INBOX"
@@ -144,11 +144,11 @@ set header_cache_backend = lmdb
# add your customizations in the following file
source ~/.rp/$profile/muttrc-custom
EOF
-echo "set imap_pass = $lpass" > ~/.rp/$profile/mutt/muttpass
+echo "set imap_pass = $lpass" > ~/.rp/"$profile"/mutt/muttpass
-touch $profile/muttrc-custom
+touch "$profile"/muttrc-custom
-cat <<EOF > $profile/config
+cat <<EOF > "$profile"/config
defaultfrom: $from
rnet: $rnet
ruser: $ruser
diff --git a/bin/rppeek b/bin/rppeek
@@ -7,11 +7,11 @@
profile="${RPPROFILE:-$HOME/.rp/default}"
usage() {
- printf " * usage: $(basename $0) [folder]\n"
+ printf " * usage: %s [folder]\\n" "$(basename "$0")"
exit 1
}
-for i in $@; do
+for i in "$@"; do
case "$i" in
-h)
usage
@@ -23,4 +23,4 @@ for i in $@; do
esac
done
-neomutt -F $profile/muttrc $folder
+neomutt -F "$profile"/muttrc $folder
diff --git a/bin/rpsend b/bin/rpsend
@@ -7,16 +7,16 @@
profile="${RPPROFILE:-$HOME/.rp/default}"
usage() {
- printf " * usage: $(basename $0) [-n] [-l] [-a] < email\n"
- printf "\t-n: dry run\n"
- printf "\t-l: list outbox\n"
- printf "\t-a: send all\n"
+ printf " * usage: %s [-n] [-l] [-a] < email\\n" "$(basename "$0")"
+ printf "\\t-n: dry run\\n"
+ printf "\\t-l: list outbox\\n"
+ printf "\\t-a: send all\\n"
exit 1
}
listoutbox() { find "$profile"/tmp/outbox -type f ; }
-for i in $@; do
+for i in "$@"; do
case "$i" in
-n)
dryrun="--pretend"
@@ -29,8 +29,8 @@ for i in $@; do
;;
-a)
echo " * sending all queued emails"
- for i in $(rpsend -l); do
- rpsend < "$i" && { [ -z "$dryrun" ] && rm -f "$i" ; }
+ for j in $(rpsend -l); do
+ rpsend < "$j" && { [ -z "$dryrun" ] && rm -f "$j" ; }
done
exit $?
;;
@@ -42,18 +42,18 @@ done
email="$(cat)"
-rnet="$(rpheaders rnet < $profile/config)"
-rimap="$(echo $rnet | cut -d'!' -f2)"
-ruser="$(rpheaders ruser < $profile/config)"
+rnet="$(rpheaders rnet < "$profile"/config)"
+rimap="$(echo "$rnet" | cut -d'!' -f2)"
+ruser="$(rpheaders ruser < "$profile"/config)"
-printf "\n\n * smtp send via %s\n" "$rimap"
+printf "\\n\\n * smtp send via %s\\n" "$rimap"
if ! [ -f "$profile/smtp-fingerprint" ]; then
echo " * no saved tls certificate fingerprint found. going with tofu."
rputil -e getfpr "$rnet" > "$profile"/smtp-fingerprint
fi
-known="$(cat $profile/smtp-fingerprint)"
+known="$(cat "$profile"/smtp-fingerprint)"
served="$(rputil -e getfpr "$rnet")"
if [ "$known" != "$served" ]; then
@@ -75,7 +75,7 @@ account default
from $ruser
user $ruser
host $rimap
-password $(rpheaders rpass < $profile/config)
+password $(rpheaders rpass < "$profile"/config)
port 587
auth plain
tls on
@@ -91,7 +91,7 @@ cat <<EOF
* subject: $_subj
* to: $_dest
* cc: $_cc
- * sending $(rputil -e humansize $(echo "$email" | wc -c)) over the network
+ * sending $(rputil -e humansize "${#email}") over the network
EOF
cat <<EOF | msmtp $dryrun -C "$msmtpcfg" -t -X "$profile/tmp/msmtp.log"
diff --git a/bin/rpsieve b/bin/rpsieve
@@ -7,14 +7,14 @@
profile="${RPPROFILE:-$HOME/.rp/default}"
usage() {
- printf " * usage: $(basename $0) [-e] [-u] [-v]\n"
- printf "\t-e: edit filters.txt before continuing\n"
- printf "\t-u: upload filters.sieve when done\n"
- printf "\t-v: be verbose\n"
+ printf " * usage: %s [-e] [-u] [-v]\\n" "$(basename "$0")"
+ printf "\\t-e: edit filters.txt before continuing\\n"
+ printf "\\t-u: upload filters.sieve when done\\n"
+ printf "\\t-v: be verbose\\n"
exit 1
}
-for i in $@; do
+for i in "$@"; do
case "$i" in
-e)
ed=true
@@ -60,8 +60,10 @@ if header :contains "Sender" "mailman-bounce" {
# own filters
EOF
-rohrpost rpsieve $verbose < "$ft" >> "$fs"
-rohrpost rpsieve $verbose < "$ab" >> "$fs"
+{
+ rohrpost rpsieve $verbose < "$ft"
+ rohrpost rpsieve $verbose < "$ab"
+} >> "$fs"
cat <<EOF >> "$fs"
# spam
@@ -74,7 +76,7 @@ EOF
if [ -n "$upload" ]; then
echo " * uploading filters.sieve"
host=t3.dyne.org
- path=/var/vmail/sieve-scripts/"$(readlink $profile)"
+ path=/var/vmail/sieve-scripts/"$(readlink "$profile")"
scp "$fs" "$host:$path" || {
echo " * upload failed"
exit 1