about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJustin <cattyhouse@users.noreply.github.com>2023-03-26 23:07:28 +0800
committerLeah Neukirchen <leah@vuxu.org>2023-03-26 19:28:33 +0200
commite27949702d25bbe0e9153cf3afea158104c0c383 (patch)
treef0350a2ad0b9640aad04f6c6d26654c155544efe
parenta7e8c3b085b64397f00a7c0baf2370f9b5a930b0 (diff)
downloadxtools-e27949702d25bbe0e9153cf3afea158104c0c383.tar.gz
xtools-e27949702d25bbe0e9153cf3afea158104c0c383.tar.xz
xtools-e27949702d25bbe0e9153cf3afea158104c0c383.zip
xdiff : make sure $DIR is valid
if user run `xdiff --help` , `--help` gets passed to find as an arg, it will cause infinite vimdiff instance coming out, has to kill xdiff's pid to stop it.
-rwxr-xr-xxdiff5
1 files changed, 5 insertions, 0 deletions
diff --git a/xdiff b/xdiff
index 626e2e5..b388c76 100755
--- a/xdiff
+++ b/xdiff
@@ -21,6 +21,11 @@ fi
 
 DIR=${1:-/etc}
 
+if ! [ -d "$DIR" ] ; then
+    echo "$DIR is not a valid directory" >&2
+    exit 1
+fi
+
 for newfile in $(find "$DIR" -name '*.new-*_*' | sort -V); do
 	$DIFF "$newfile" "${newfile%.new-*_*}"
 done