4 # Later, we're going to want to set $IFS to a single newline, so let's prepare one.
16 [ -d "$o" ] && printf "%s/\n" "$o" ||
printf "%s\n" "$o"
20 while [ $# -gt 0 ]; do
23 echo "usage: $(basename $0) [-h] [-p prompt] [-f] [--] [file-pattern]"
45 # At this point, all the remaining arguments should be the expansion of
46 # any globs that were passed on the command line.
48 if [ $# -eq 1 -a "$ALLOW_AUTO_SELECT" = 1 ]; then
49 # If there were globs on the command-line, they've expanded to
50 # a single item, so we can just process it.
53 # Recurse and show the contents of the named directory,
54 # We pass -f to force the next iteration to present the
55 # full list, even if it's just an empty directory.
57 IFS
=$NL # Don't split ls output on tabs or spaces.
58 exec "$0" -p "$VIS_MENU_PROMPT" -f .. $
(ls -1)
60 # We've found a single item, and it's not a directory,
61 # so it must be a filename (or file-like thing) to open,
62 # unless the parent directory does not exist.
63 if [ -d "$(dirname "$1")" ]; then
65 echo "$(pwd -P)"/"$(basename "$1" | sed 's/\*$//')"
73 # At this point, we have a bunch of options we need to present to the
74 # user so they can pick one.
75 CHOICE
=$
(printf "%s\n" "$@" | wrap_dirs | vis-menu
-b -p "$VIS_MENU_PROMPT")
77 # Did they pick a file or directory? Who knows, let's let the next iteration figure it out.
78 exec "$0" -p "$VIS_MENU_PROMPT" -- "$CHOICE"