aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-01-04 11:23:50 -0300
committerEuAndreh <eu@euandre.org>2024-01-04 11:23:55 -0300
commit07455024c72c3aa0bacf8338b82d3a0b8a96a9b0 (patch)
treec3e7074928e2783d9e97001f45e2a3522d52ba76 /bin
parentetc/sh/rc: Fix "c" alias to use the correct command (diff)
downloaddotfiles-07455024c72c3aa0bacf8338b82d3a0b8a96a9b0.tar.gz
dotfiles-07455024c72c3aa0bacf8338b82d3a0b8a96a9b0.tar.xz
re "s|echo \"\\\$|printf '%s\\\n' \"\$|g"
Replace all cases where `echo` was given a variable as its first argument, even on cases where we always know what the variable's content look like.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/free-port2
-rwxr-xr-xbin/grun2
-rwxr-xr-xbin/max2
-rwxr-xr-xbin/menu4
-rwxr-xr-xbin/min2
-rwxr-xr-xbin/mkdtemp2
-rwxr-xr-xbin/mkstemp2
-rwxr-xr-xbin/msg2
-rwxr-xr-xbin/muffle6
-rwxr-xr-xbin/player14
-rwxr-xr-xbin/playlist4
-rwxr-xr-xbin/repos8
-rwxr-xr-xbin/tmpname2
-rwxr-xr-xbin/vcs12
-rwxr-xr-xbin/vm10
15 files changed, 37 insertions, 37 deletions
diff --git a/bin/free-port b/bin/free-port
index 30ed0ff..e3b5a20 100755
--- a/bin/free-port
+++ b/bin/free-port
@@ -75,4 +75,4 @@ while true; do
fi
done
-echo "$PORT"
+printf '%s\n' "$PORT"
diff --git a/bin/grun b/bin/grun
index 46576c1..bc46237 100755
--- a/bin/grun
+++ b/bin/grun
@@ -98,4 +98,4 @@ fi
# GPG recipients can't contain spaces:
# shellcheck disable=2086
-echo "$OUT" | gpg -e ${RECIPIENTS_FLAG:--r eu@euandre.org} | sponge "$FILENAME"
+printf '%s\n' "$OUT" | gpg -e ${RECIPIENTS_FLAG:--r eu@euandre.org} | sponge "$FILENAME"
diff --git a/bin/max b/bin/max
index ea0cba5..9b88619 100755
--- a/bin/max
+++ b/bin/max
@@ -88,4 +88,4 @@ N="$1"
for n in "$@"; do
N=$((N > n ? N : n))
done
-echo "$N"
+printf '%s\n' "$N"
diff --git a/bin/menu b/bin/menu
index 875f084..296b522 100755
--- a/bin/menu
+++ b/bin/menu
@@ -113,8 +113,8 @@ case "$ACTION" in
emoji)
CHOICE="$(DATA | show 'emoji')"
if [ -n "$CHOICE" ]; then
- EMOJI="$(echo "$CHOICE" | awk '{print $(NF)}')"
- echo "$EMOJI" | copy -n
+ EMOJI="$(printf '%s\n' "$CHOICE" | awk '{print $(NF)}')"
+ printf '%s\n' "$EMOJI" | copy -n
notify-send -t 5000 -u normal -- \
"$EMOJI" 'emoji copied to clipboard'
fi
diff --git a/bin/min b/bin/min
index d513cb7..e20484d 100755
--- a/bin/min
+++ b/bin/min
@@ -88,4 +88,4 @@ N="$1"
for n in "$@"; do
N=$((N < n ? N : n))
done
-echo "$N"
+printf '%s\n' "$N"
diff --git a/bin/mkdtemp b/bin/mkdtemp
index 8e5fb48..3c920a8 100755
--- a/bin/mkdtemp
+++ b/bin/mkdtemp
@@ -62,4 +62,4 @@ shift $((OPTIND - 1))
name="$(tmpname)"
mkdir "$name"
-echo "$name"
+printf '%s\n' "$name"
diff --git a/bin/mkstemp b/bin/mkstemp
index 2c0cdbc..ec0d744 100755
--- a/bin/mkstemp
+++ b/bin/mkstemp
@@ -62,4 +62,4 @@ shift $((OPTIND - 1))
name="$(tmpname)"
touch "$name"
-echo "$name"
+printf '%s\n' "$name"
diff --git a/bin/msg b/bin/msg
index 80491be..486eeda 100755
--- a/bin/msg
+++ b/bin/msg
@@ -138,7 +138,7 @@ if [ "$SOUND" = true ]; then
fi
if [ "$SPEAK" = true ]; then
eval "$(assert-arg -- "$MESSAGE" '-S MESSAGE')"
- echo "$MESSAGE" | speak -v pt-BR &
+ printf '%s\n' "$MESSAGE" | speak -v pt-BR &
fi
if [ "$MAIL" = true ]; then
eval "$(assert-arg -- "$MESSAGE" '-m MESSAGE')"
diff --git a/bin/muffle b/bin/muffle
index 6f93306..35d1ee6 100755
--- a/bin/muffle
+++ b/bin/muffle
@@ -83,10 +83,10 @@ STATUS="$(cat "$STATUS_F")"
if [ "$STATUS" != 0 ]; then
cat "$OUT" "$ERR" |
sort -k2 | while read -r line; do
- if [ "$(echo "$line" | cut -d' ' -f1)" = 'out:' ]; then
- echo "$line" | cut -d' ' -f3- >&1
+ if [ "$(printf '%s\n' "$line" | cut -d' ' -f1)" = 'out:' ]; then
+ printf '%s\n' "$line" | cut -d' ' -f3- >&1
else
- echo "$line" | cut -d' ' -f3- >&2
+ printf '%s\n' "$line" | cut -d' ' -f3- >&2
fi
done
exit "$STATUS"
diff --git a/bin/player b/bin/player
index b83e8c0..129942e 100755
--- a/bin/player
+++ b/bin/player
@@ -83,24 +83,24 @@ CURRENT_PLAYER="$(cat "$CURRENT_PLAYER_PATH" ||:)"
AVAILABLE_PLAYERS="$(playerctl --list-all | LANG=POSIX.UTF-8 sort)"
pick_first() {
- echo "$AVAILABLE_PLAYERS" | head -n1
+ printf '%s\n' "$AVAILABLE_PLAYERS" | head -n1
}
next_player() {
if [ -z "$CURRENT_PLAYER" ]; then
pick_first
- elif ! echo "$AVAILABLE_PLAYERS" | grep -q "$CURRENT_PLAYER"; then
+ elif ! printf '%s\n' "$AVAILABLE_PLAYERS" | grep -q "$CURRENT_PLAYER"; then
# Unknown $CURRENT_PLAYER, pick anyone
pick_first
else
- INDEX="$(echo "$AVAILABLE_PLAYERS" | grep -n "$CURRENT_PLAYER" | cut -d: -f1)"
- LENGTH="$(echo "$AVAILABLE_PLAYERS" | wc -l)"
+ INDEX="$(printf '%s\n' "$AVAILABLE_PLAYERS" | grep -n "$CURRENT_PLAYER" | cut -d: -f1)"
+ LENGTH="$(printf '%s\n' "$AVAILABLE_PLAYERS" | wc -l)"
if [ "$INDEX" = "$LENGTH" ]; then
# Reached the end of the $AVAILABLE_PLAYERS list, wrapping
pick_first
else
# Get the next player instead
- echo "$AVAILABLE_PLAYERS" | awk -v idx="$INDEX" 'NR == idx+1 {print}'
+ printf '%s\n' "$AVAILABLE_PLAYERS" | awk -v idx="$INDEX" 'NR == idx+1 {print}'
fi
fi
}
@@ -146,14 +146,14 @@ case "$ACTION" in
;;
rotate)
PLAYER="$(next_player)"
- echo "$PLAYER" > "$CURRENT_PLAYER_PATH"
+ printf '%s\n' "$PLAYER" > "$CURRENT_PLAYER_PATH"
notify-send -t 1000 -- \
"$(printf '%s' "$PLAYER" | format_player_name)" \
'current MPRIS target'
;;
synopsis)
printf '%s: %s\n' \
- "$(echo "$CURRENT_PLAYER" | format_player_name)" \
+ "$(printf '%s\n' "$CURRENT_PLAYER" | format_player_name)" \
"$(formatted_player_title)"
;;
*)
diff --git a/bin/playlist b/bin/playlist
index bfb609e..0c29169 100755
--- a/bin/playlist
+++ b/bin/playlist
@@ -75,7 +75,7 @@ F="$XDG_DATA_HOME"/euandreh/playlist.txt
prompt() {
ENTRY="$(zenity --text 'URL of the video to enqueue:' --entry ||:)"
if [ -n "$ENTRY" ]; then
- echo "$ENTRY" >> "$F"
+ printf '%s\n' "$ENTRY" >> "$F"
fi
}
@@ -85,7 +85,7 @@ run() {
return
fi
mpv "$next"
- echo "$next" >> "queue.$F"
+ printf '%s\n' "$next" >> "queue.$F"
tail -n+2 "$F" | sponge "$F"
}
diff --git a/bin/repos b/bin/repos
index 25f7725..2cb6987 100755
--- a/bin/repos
+++ b/bin/repos
@@ -77,15 +77,15 @@ arr_push() {
ARR="$1"
ELT="$2"
if [ -n "$ARR" ]; then
- echo "$ARR"
+ printf '%s\n' "$ARR"
fi
- echo "$ELT" # | array_encode (see CAVEAT)
+ printf '%s\n' "$ELT" # | array_encode (see CAVEAT)
}
arr_includes() {
ARR="$1"
ELT="$2"
- echo "$ARR" | while read -r el; do
+ printf '%s\n' "$ARR" | while read -r el; do
# if [ "$(printf '%s\n' "$el" | array_decode)" = "$ELT" ]; then (see CAVEAT)
if [ "$el" = "$ELT" ]; then
return 2
@@ -133,7 +133,7 @@ shift $((OPTIND - 1))
is_repository() {
TYPE="$(vcs -C "$1" -t 2>/dev/null)"
if [ -n "$TYPE" ]; then
- echo "$1"
+ printf '%s\n' "$1"
else
return 1
fi
diff --git a/bin/tmpname b/bin/tmpname
index 5b732a5..f16816e 100755
--- a/bin/tmpname
+++ b/bin/tmpname
@@ -64,4 +64,4 @@ while getopts 'h' flag; do
done
shift $((OPTIND - 1))
-echo "${TMPDIR:-/tmp}/uuid-tmpname with spaces.$(uuid)"
+printf '%s\n' "${TMPDIR:-/tmp}/uuid-tmpname with spaces.$(uuid)"
diff --git a/bin/vcs b/bin/vcs
index b51cf33..2f2c4f6 100755
--- a/bin/vcs
+++ b/bin/vcs
@@ -68,15 +68,15 @@ git_diff() {
git_ps1() {
BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
OUT="$(git status --short --branch --porcelain)"
- BRANCH_LINE="$(echo "$OUT" | head -n 1)"
- DIFF_LINES="$(echo "$OUT" | tail -n +2)"
+ BRANCH_LINE="$(printf '%s\n' "$OUT" | head -n 1)"
+ DIFF_LINES="$(printf '%s\n' "$OUT" | tail -n +2)"
IS_AHEAD=false
IS_BEHIND=false
- if echo "$BRANCH_LINE" | grep -q 'ahead'; then
+ if printf '%s\n' "$BRANCH_LINE" | grep -q 'ahead'; then
IS_AHEAD=true
fi
- if echo "$BRANCH_LINE" | grep -q 'behind'; then
+ if printf '%s\n' "$BRANCH_LINE" | grep -q 'behind'; then
IS_BEHIND=true
fi
@@ -94,10 +94,10 @@ git_ps1() {
HAS_DIFF=false
HAS_UNTRACKED=false
- if echo "$DIFF_LINES" | grep -q '^[A|D|M| ][M|D| ]'; then
+ if printf '%s\n' "$DIFF_LINES" | grep -q '^[A|D|M| ][M|D| ]'; then
HAS_DIFF=true
fi
- if echo "$DIFF_LINES" | grep -Eq '^([?][?]| A)'; then
+ if printf '%s\n' "$DIFF_LINES" | grep -Eq '^([?][?]| A)'; then
HAS_UNTRACKED=true
fi
diff --git a/bin/vm b/bin/vm
index b123ee5..1b7c878 100755
--- a/bin/vm
+++ b/bin/vm
@@ -163,7 +163,7 @@ mkdir -p "$RUNDIR" "$QCOW_DIR" "$XDG_DATA_HOME"/vm "$(dirname "$LOGS")"
guess_name() {
PREFIX="$1"
IMAGES="$(find "$QCOW_DIR" '(' -type f -or -type l ')' -name "${PREFIX}*")"
- COUNT="$(echo "$IMAGES" | wc -l)"
+ COUNT="$(printf '%s\n' "$IMAGES" | wc -l)"
if [ "$COUNT" != 1 ]; then
printf 'Cannot guess name with the given prefix: "%s".\n' "$PREFIX" >&2
printf '\nThe possibilities are:\n' >&2
@@ -181,7 +181,7 @@ guess_name() {
}
guess_arch() {
- NAME="$(echo "$1" | cut -d- -f2)"
+ NAME="$(printf '%s\n' "$1" | cut -d- -f2)"
case "$NAME" in
amd64)
printf 'x86_64'
@@ -194,8 +194,8 @@ guess_arch() {
hostfwd() {
for m in "$@"; do
- HOST="$( echo "$m" | cut -d: -f1)"
- GUEST="$(echo "$m" | cut -d: -f2)"
+ HOST="$( printf '%s\n' "$m" | cut -d: -f1)"
+ GUEST="$(printf '%s\n' "$m" | cut -d: -f2)"
printf ',hostfwd=tcp::%s-:%s' "$HOST" "$GUEST"
done
}
@@ -304,7 +304,7 @@ case "$ACTION" in
$FLAGS "$@"
if [ "$DRY_RUN" = true ]; then
- echo "$@"
+ printf '%s\n' "$@"
exit
fi