From 9c1c4ea34cde7ce0573769f42b7fe7f589a25540 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 31 Jul 2022 20:56:47 -0500 Subject: Shellcheck --- autoshart | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/autoshart b/autoshart index 514e264..a1d265b 100755 --- a/autoshart +++ b/autoshart @@ -30,6 +30,7 @@ FLAGS: -n Only print what would happen; don't execute anything. -q Don't print any output. EOF + exit "$1" } main() { @@ -43,6 +44,10 @@ main() { k) auto_kill ;; n) RUN=false ;; q) QUIET=true ;; + *) + echo >&2 "Unknown option: -$opt" + usage 1 + ;; esac done shift "$((OPTIND - 1))" @@ -52,7 +57,7 @@ main() { ## Library functions auto_kill() { - cat "$PID_FILE" | xargs kill + xargs kill <"$PID_FILE" } auto_start() { ## auto_start FILE @@ -129,7 +134,7 @@ auto_start() { ## auto_start FILE # This is so cursed quit="$( echo "$XDG_CURRENT_DESKTOP" | tr : \\n | - while read desktop; do + while read -r desktop; do case "$onlyshowin;$notshowin" in *$desktop*) if test -n "$onlyshowin"; then @@ -196,7 +201,7 @@ auto_search() { ## auto_search # ~/.config/autostart/ is more important than /etc/xdg/autostart/ echo "${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}" | tr : \\n | sed 's,$,/autostart,' | - while read dir; do + while read -r dir; do if test -d "$dir"; then for desktop in "$dir"/*.desktop; do if ! grep -q "$desktop" "$FOUND_FILE"; then @@ -231,9 +236,9 @@ eprint() { die() { errcode="$1" shift - eprint "! $@" - echo $errcode - exit $errcode + eprint "! $*" + echo "$errcode" + exit "$errcode" } ## Entry point -- cgit 1.4.1-21-gabe81