Skip to content

Commit

Permalink
vis-open: fix creating new files in selected directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kj committed Jan 4, 2018
1 parent 664b3ee commit 0be1e2e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions vis-open
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 0be1e2e

Please sign in to comment.