From f28d694879239d5d9c319185a278236d317a49b6 Mon Sep 17 00:00:00 2001 From: zachir Date: Sat, 30 Aug 2025 01:09:18 -0500 Subject: Make sh scrips POSIX compliant Using shellcheck, I went through all of them to make them standards compliant. I also tested as many as I could. --- dmpv | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'dmpv') diff --git a/dmpv b/dmpv index d0dc214..dc98c80 100755 --- a/dmpv +++ b/dmpv @@ -1,6 +1,6 @@ #!/bin/sh -cd ~/Videos +cd ~/Videos || exit case "$@" in "-l") LOOP="true" @@ -12,12 +12,12 @@ esac playvid () { while true; do - VIDEO=$(printf ".\n%s\n" "$(ls)" | uniq | dmenu -l 15 "$@") - [ -z $VIDEO ] && exit + VIDEO=$(find "$HOME/Videos" | uniq | dmenu -l 15) + [ -z "$VIDEO" ] && exit if [ "$VIDEO" = "." ]; then break; fi - [ -d $VIDEO ] && cd $VIDEO && continue + [ -d "$VIDEO" ] && cd "$VIDEO" && continue [ -f "$VIDEO" ] && break pwd done @@ -25,12 +25,11 @@ playvid () { } printhelp () { - printf \ - "Usage: dmpv [-l] [-h]\n" \ - "dmpv is a simple dmenu interface for playing content with mpv\n" \ - "dmpv assumes videos are stored in ~/Videos\n" \ - " -h\t\tprint this help message\n" \ - " -l\t\trun the prompt again after mpv exits\n" + printf "Usage: dmpv [-l] [-h]\n" + printf "dmpv is a simple dmenu interface for playing content with mpv\n" + printf "dmpv assumes videos are stored in ~/Videos\n" + printf " -h\t\tprint this help message\n" + printf " -l\t\trun the prompt again after mpv exits\n" } if [ -n "$HELP" ]; then @@ -39,8 +38,6 @@ elif [ -n "$LOOP" ]; then while true; do playvid || exit 0 done -fi - -playvid - done +else + playvid fi -- cgit v1.2.3