aboutsummaryrefslogtreecommitdiff
path: root/array.h
diff options
context:
space:
mode:
authorTim Allen <screwtape@froup.com>2016-05-22 21:30:43 +1000
committerTim Allen <screwtape@froup.com>2016-05-28 17:49:51 +1000
commitcb53860369efa1a70a59a804ba88ba755be0acc1 (patch)
treefb2539b76eafd42db2683988d7c0b2e7ecf92c04 /array.h
parentc5668016204d028fddc7a14d056b629095b527cf (diff)
downloadvis-cb53860369efa1a70a59a804ba88ba755be0acc1.tar.gz
vis-cb53860369efa1a70a59a804ba88ba755be0acc1.tar.xz
Rewrite vis-open to be more robust.
Rather than try to loop manually and build up a path, this new version exec's itself for each new directory scanned. Functional changes include: - We `set -e` at the top of the script, so any surprising permission-denied errors will automatically cause the script to exit with a helpful error message. - We now support the GNU "--" convention for splitting options from filename arguments, just in case somebody happens across a directory with a file named "-h" or "-p". - If launched with a single filename parameter, we automatically return it - if somebody writes ":e somepattern*" and it matches exactly one file, we might as well open it directly. - If we select a single filename parameter, we use `realpath` to build an absolute path for it - much more reliable than trying to build up a path while the user is navigating around. - If launched with a single directory parameter, we change into that directory and re-exec ourselves with ".." and all the files in that directory as arguments. This means we don't have to handle selection and recursion at the same time. - Note that if we recurse into a directory, we pass the "-f" parameter to suppress auto-selection - otherwise recursing into an empty directory would immediately select the ".." entry and pop you back out, which would be confusing. - The new version doesn't bother trying to manipulate `$VIS_MENU_ARGS` and sometimes add a prompt to it. Setting no prompt is the same as setting the prompt to an empty string, so we can just use an empty string as the default value. One specific use-case that this change cleans up is giving ":e" a pattern that matches multiple directories (for example, running ":e *e*" in the root of the vis repo). "ls -1" would list the contents of each directory (without a prefix, so you couldn't select those files) but would also print the directory names as headings followed by a colon, so you couldn't usefully select the directory names either. We get around this by only ever running "ls -1" without any arguments, so it only scans the current directory.
Diffstat (limited to 'array.h')
0 files changed, 0 insertions, 0 deletions