vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 42c92ea876dce9d9190437547a3039cb03f2428a
parent 495f1c6f83331a9df22f44931eef5b2e1b7ac84d
Author: Kelsey Judson <kelseyjudson@protonmail.com>
Date:   Thu,  4 Jan 2018 19:05:28 +1300

vis-open: fix creating new files in selected directory

Diffstat:
Mvis-open | 18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git 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