aboutsummaryrefslogtreecommitdiff
path: root/vis-open
diff options
context:
space:
mode:
authorKelsey Judson <kelseyjudson@protonmail.com>2018-01-04 19:05:28 +1300
committerKelsey Judson <kelseyjudson@protonmail.com>2018-01-04 19:05:28 +1300
commit0be1e2e70b797e7e3149d777a26bc69966079e07 (patch)
tree31d50ddfd5cc2603825d484fefe7565986f14ad5 /vis-open
parent664b3ee8b72ef815227b9f1fd76ee0ca72f3704a (diff)
downloadvis-0be1e2e70b797e7e3149d777a26bc69966079e07.tar.gz
vis-0be1e2e70b797e7e3149d777a26bc69966079e07.tar.xz
vis-open: fix creating new files in selected directory
Diffstat (limited to 'vis-open')
-rwxr-xr-xvis-open18
1 files 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