Redirect stderr on "which" calls to clear up error noise
authorSteve McIntyre <steve@einval.com>
Sun, 25 Feb 2018 23:14:16 +0000 (23:14 +0000)
committerSteve McIntyre <steve@einval.com>
Sun, 25 Feb 2018 23:14:16 +0000 (23:14 +0000)
on some systems. Closes Issue 56:
https://abcde.einval.com/bugzilla/show_bug.cgi?id=56

abcde
changelog

diff --git a/abcde b/abcde
index 1c02676..4c265ed 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -339,9 +339,9 @@ new_checkexec ()
        if [ ! "$@" = "" ]; then
                # Cut off any command-line option we added in
                X=$(echo $@ | cut -d' ' -f2)
-               if [ "$(which $X)" = "" ]; then
+               if [ "$(which $X 2>/dev/null)" = "" ]; then
                        return 1
-               elif [ ! -x $(which $X) ]; then
+               elif [ ! -x $(which $X 2>/dev/null) ]; then
                        return 2
                fi
        fi
@@ -355,7 +355,7 @@ checkexec ()
                X=$(echo $@ | cut -d' ' -f2)
                # Test for built-in abcde.function
                [ "$X" != "${X#abcde.}" ] && type $X >/dev/null 2>&1 && return
-               if [ "$(which $X)" = "" ]; then
+               if [ "$(which $X 2>/dev/null)" = "" ]; then
                        log error "$X is not in your path." >&2
                        log info  "Define the full path to the executable if it exists on your system." >&2
                        if [ -e /etc/debian_* ] ; then
@@ -366,7 +366,7 @@ checkexec ()
                                log info "Hint: sudo apt-get install $MISSING_PACKAGE" >&2
                        fi
                        exit 1
-               elif [ ! -x "$(which $X)" ]; then
+               elif [ ! -x "$(which $X 2>/dev/null)" ]; then
                        log error "$X is not executable." >&2
                        exit 1
                fi
index 896cb5d..da66a2c 100644 (file)
--- a/changelog
+++ b/changelog
@@ -71,6 +71,9 @@ abcde 2.8.2
  * Add a more better fix for the year lookup problem in abcde-musicbrainz-tool
    Thanks to Tom Samstag for the patch. Closes Issue 57:
    https://abcde.einval.com/bugzilla/show_bug.cgi?id=57
+ * Redirect stderr on "which" calls to clear up error noise on some
+   systems. Closes Issue 56:
+   https://abcde.einval.com/bugzilla/show_bug.cgi?id=56
    
 abcde 2.8.1.