4 # Later, we're going to want to set $IFS to a single newline, so let's prepare one.
11 while [ $# -gt 0 ]; do
14 echo "usage: $(basename $0) [-h] [-p prompt] [-f] [--] [file-pattern]"
36 # At this point, all the remaining arguments should be the expansion of
37 # any globs that were passed on the command line.
39 if [ $# -eq 1 -a "$ALLOW_AUTO_SELECT" = 1 ]; then
40 # If there were globs on the command-line, they've expanded to
41 # a single item, so we can just process it.
44 # Recurse and show the contents of the named directory,
45 # We pass -f to force the next iteration to present the
46 # full list, even if it's just an empty directory.
48 IFS
=$NL # Don't split ls output on tabs or spaces.
49 exec "$0" -p "$VIS_MENU_PROMPT" -f .. $
(ls -1)
51 # We've found a single item, and it's not a directory,
52 # so it must be a filename (or file-like thing) to open.
54 echo "$(pwd -P)"/"$(basename "$1")"
59 # At this point, we have a bunch of options we need to present to the
60 # user so they can pick one.
61 CHOICE
=$
(printf "%s\n" "$@" | vis-menu
-b -p "$VIS_MENU_PROMPT")
63 # Did they pick a file or directory? Who knows, let's let the next iteration figure it out.
64 exec "$0" -p "$VIS_MENU_PROMPT" -- "$CHOICE"