Closed junegunn closed 1 week ago
I guess you have already found the desired formula.
print -nr -- …
should have worked as well.
--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -53,6 +53,6 @@ __fzf_select() {
FZF_DEFAULT_COMMAND=${FZF_CTRL_T_COMMAND:-} \
FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --walker=file,dir,follow,hidden --scheme=path" "${FZF_CTRL_T_OPTS-} -m") \
- FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) "$@" < /dev/tty | while read item; do
- echo -n "${(q)item} "
+ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) "$@" < /dev/tty | while read -r item; do
+ print -nr -- "${(q)item} "
done
local ret=$?
or bsd_echo
--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -49,9 +49,9 @@ __fzf_defaults() {
# CTRL-T - Paste the selected file path(s) into the command line
__fzf_select() {
- setopt localoptions pipefail no_aliases 2> /dev/null
+ setopt localoptions pipefail no_aliases bsd_echo 2> /dev/null
local item
FZF_DEFAULT_COMMAND=${FZF_CTRL_T_COMMAND:-} \
FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --walker=file,dir,follow,hidden --scheme=path" "${FZF_CTRL_T_OPTS-} -m") \
- FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) "$@" < /dev/tty | while read item; do
+ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) "$@" < /dev/tty | while read -r item; do
echo -n "${(q)item} "
done
Thanks. Do they have pros and cons or are they more or less the same and it doesn't matter which one we choose?
Thanks. Do they have pros and cons or are they more or less the same and it doesn't matter which one we choose?
Difference between echo
and print
.
3.2.1: Builtins for printing The commands
echo' and
print' are shell builtins; they just show what you typed, after the shell has removed all the quoting. The difference between the two is really historical:echo' came first, and only handled a few simple options; ksh provided
print', which had more complex options and so became a different command. The difference remains between the two commands in zsh; if you want wacky effects, you should look to print. Note that there is usually also an external command called echo, which may not be identical to zsh's; there is no standard external command called print, but if someone has installed one on your system, the chances are it sends something to the printer, not the screen.Source: A User's Guide to the Z-Shell
print
comes with more flags, making it useful for special cases, but using echo -nE
or print -nr --
is indifferent here.
Fix #3859
To test: