mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 12:21:19 -03:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user