aboutsummaryrefslogtreecommitdiff
path: root/vis-open
diff options
context:
space:
mode:
authorTim Allen <screwtape@froup.com>2016-05-25 20:09:15 +1000
committerTim Allen <screwtape@froup.com>2016-05-28 17:49:51 +1000
commit958dc002a077997358361d9bff7a245137307d78 (patch)
tree039bb3285f05c44e3211250ea66e07472d2f6744 /vis-open
parent5e7122cf03f842b8afa098e18f97b968b6080214 (diff)
downloadvis-958dc002a077997358361d9bff7a245137307d78.tar.gz
vis-958dc002a077997358361d9bff7a245137307d78.tar.xz
[vis-open] Handle filenames with spaces and tabs.
We still don't handle filenames that contain newlines, but we're pressing against the limits of what portable POSIX shell can do. Besides which, we're ultimately plumbing filenames into vis-menu which uses newlines as a delimiter *anyway*, so there's not much we can do.
Diffstat (limited to 'vis-open')
-rwxr-xr-xvis-open5
1 files changed, 5 insertions, 0 deletions
diff --git a/vis-open b/vis-open
index 554f0d1..b6bf664 100755
--- a/vis-open
+++ b/vis-open
@@ -1,6 +1,10 @@
#!/bin/sh
set -e
+# Later, we're going to want to set $IFS to a single newline, so let's prepare one.
+NL='
+'
+
VIS_MENU_PROMPT=""
ALLOW_AUTO_SELECT=1
@@ -41,6 +45,7 @@ if [ $# -eq 1 -a "$ALLOW_AUTO_SELECT" = 1 ]; then
# We pass -f to force the next iteration to present the
# full list, even if it's just an empty directory.
cd "$1"
+ IFS=$NL # Don't split ls output on tabs or spaces.
exec "$0" -p "$VIS_MENU_PROMPT" -f .. $(ls -1)
else
# We've found a single item, and it's not a directory,