From 664b3ee8b72ef815227b9f1fd76ee0ca72f3704a Mon Sep 17 00:00:00 2001 From: Kelsey Judson Date: Mon, 1 Jan 2018 19:52:40 +1300 Subject: vis-open: fix for absolute and non-existent paths When the shell cannot find any matching files, the glob is not expanded, and vis-open will return the absolute path of the current working directory (because dirname outputs '.'), followed by the filename, followed by a literal '*'. This commit checks that the final path actually exists, and if not, exits with status 1. It also uses text_object_longword for the range to match, so that absolute paths are accepted, and replaced properly (else it only works back to the first '/'). --- vis-open | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'vis-open') diff --git a/vis-open b/vis-open index 997aa49..cb81b04 100755 --- a/vis-open +++ b/vis-open @@ -40,6 +40,11 @@ if [ $# -eq 1 -a "$ALLOW_AUTO_SELECT" = 1 ]; then # If there were globs on the command-line, they've expanded to # a single item, so we can just process it. + # If the file or directory does not exist, abort. + if [ ! -e "$1" ]; then + exit 1 + fi + if [ -d "$1" ]; then # Recurse and show the contents of the named directory, # We pass -f to force the next iteration to present the -- cgit v1.2.3