From 958dc002a077997358361d9bff7a245137307d78 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Wed, 25 May 2016 20:09:15 +1000 Subject: [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. --- vis-open | 5 +++++ 1 file changed, 5 insertions(+) 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, -- cgit v1.2.3