From 0be1e2e70b797e7e3149d777a26bc69966079e07 Mon Sep 17 00:00:00 2001 From: Kelsey Judson Date: Thu, 4 Jan 2018 19:05:28 +1300 Subject: vis-open: fix creating new files in selected directory --- vis-open | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/vis-open b/vis-open index cb81b04..920239c 100755 --- a/vis-open +++ b/vis-open @@ -40,11 +40,6 @@ 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 @@ -54,10 +49,15 @@ if [ $# -eq 1 -a "$ALLOW_AUTO_SELECT" = 1 ]; then exec "$0" -p "$VIS_MENU_PROMPT" -f .. $(ls -1) else # We've found a single item, and it's not a directory, - # so it must be a filename (or file-like thing) to open. - cd "$(dirname "$1")" - echo "$(pwd -P)"/"$(basename "$1")" - exit 0 + # so it must be a filename (or file-like thing) to open, + # unless the parent directory does not exist. + if [ -d "$(dirname "$1")" ]; then + cd "$(dirname "$1")" + echo "$(pwd -P)"/"$(basename "$1" | sed 's/\*$//')" + exit 0 + else + exit 1 + fi fi fi -- cgit v1.2.3