Use shellcheck

This also adds set -e and friends where applicable.
This commit is contained in:
Simon Bruder 2021-05-31 23:59:13 +02:00
parent 56b9c6c37f
commit b0d6861825
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
5 changed files with 12 additions and 6 deletions

View file

@ -63,6 +63,7 @@
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
shellcheck.enable = true;
};
};
};
@ -138,6 +139,7 @@
devShell = pkgs.mkShell {
buildInputs = (with pkgs; [
nixpkgs-fmt
shellcheck
sops
ssh-to-pgp
]);

View file

@ -2,6 +2,6 @@
set -eo pipefail
card=$(pactl list cards short | grep -E -o "bluez_card.*" | cut -f1)
# pactl does not support any easily parsable output format
profile=$(pactl list cards | rg -oU "Name: ${card}.*(\\n.*?)*.*Active Profile: (.*)" -r '$2')
pacmd set-card-profile $card off
pacmd set-card-profile $card "$profile"
profile=$(pactl list cards | rg -oU "Name: ${card}.*(\\n.*?)*.*Active Profile: (.*)" -r "\$2")
pacmd set-card-profile "$card" off
pacmd set-card-profile "$card" "$profile"

View file

@ -1,2 +1,3 @@
#!/usr/bin/env bash
mkvextract "$1" attachments $(mkvmerge --identify "$1" | grep "Attachment ID" | sed "s/Attachment ID \([0-9]*\): .*/\1/")
set -eo pipefail
mkvextract "$1" attachments "$(mkvmerge --identify "$1" | grep "Attachment ID" | sed "s/Attachment ID \([0-9]*\): .*/\1/")"

View file

@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e
file="$1"
shift
for attachment in "$@"; do

View file

@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
if (( $# < 2 )); then
echo "USAGE: $0 DIGITS FILES"
return 1
@ -6,7 +7,8 @@ fi
digits="$1"
shift 1
i=1
for file in $@; do
mv -n "$file" "$(dirname $file)/$(printf %0${digits}d $i).${file##*.}"
for file in "$@"; do
file="$(readlink -f "$file")"
mv -n "$file" "${file%/*}/$(printf "%0${digits}d" "$i").${file##*.}"
i="$((i+1))"
done