remove some uses of $IFS

This is a step towards resolving issue #4156. It replaces uses of `$IFS`
with other solutions.
This commit is contained in:
Kurtis Rader
2017-07-24 20:45:43 -07:00
parent 6f46f6b45a
commit 8e87d595b7
9 changed files with 187 additions and 228 deletions

View File

@@ -56,25 +56,21 @@ function funced --description 'Edit function definition'
end
if test "$editor" = fish
set -l IFS
if functions -q -- $funcname
# Shadow IFS here to avoid array splitting in command substitution
set init (functions -- $funcname | fish_indent --no-indent)
functions -- $funcname | fish_indent --no-indent | read -z init
end
set -l prompt 'printf "%s%s%s> " (set_color green) '$funcname' (set_color normal)'
# Unshadow IFS since the fish_title breaks otherwise
set -e IFS
if read -p $prompt -c "$init" -s cmd
# Shadow IFS _again_ to avoid array splitting in command substitution
set -l IFS
eval (echo -n $cmd | fish_indent)
echo -n $cmd | fish_indent | read -lz cmd
eval "$cmd"
end
return 0
end
# OSX mktemp is rather restricted - no suffix, no way to automatically use TMPDIR
# Create a directory so we can use a ".fish" suffix for the file - makes editors pick up that it's a fish file
# OS X (macOS) `mktemp` is rather restricted - no suffix, no way to automatically use TMPDIR.
# Create a directory so we can use a ".fish" suffix for the file - makes editors pick up that
# it's a fish file.
set -q TMPDIR
or set -l TMPDIR /tmp
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)