btrfs-progs: tests: fix _is_file_or_command detection
authorDavid Sterba <dsterba@suse.com>
Fri, 25 Aug 2017 13:44:24 +0000 (15:44 +0200)
committerDavid Sterba <dsterba@suse.com>
Fri, 25 Aug 2017 13:58:05 +0000 (15:58 +0200)
type -p returns an empty string for nonexistent commands, but the -f
test on an empty string does not behave the same on all shells. To be
safe, use the quoted value.

Signed-off-by: David Sterba <dsterba@suse.com>
tests/common

index a1ab3e0..d0324a6 100644 (file)
@@ -35,7 +35,8 @@ _is_file_or_command()
        if [ -f "$msg" -o -d "$msg" -o -b "$msg" ]; then
                return 0
        fi
-       if [ -f $(type -p "$msg") ]; then
+       msg=$(type -p "$msg")
+       if [ -f "$msg" ]; then
                return 0
        fi
        return 1