* Getting the command in preexec as precisely typed @ 2019-06-02 14:45 Sylvia Gough 2019-06-02 16:03 ` Sebastian Gniazdowski 0 siblings, 1 reply; 5+ messages in thread From: Sylvia Gough @ 2019-06-02 14:45 UTC (permalink / raw) To: zsh-users [-- Attachment #1: Type: text/plain, Size: 602 bytes --] Hey, The zsh manual says about `preexec` that: "the string that the user typed is passed as the first argument". This mostly work as expected, but I found cases where there is some expansion going on. In order to debug the issue I'm seeing, I have this zsh code run from my zshrc: ```zsh echo_preexec_command() { echo "$1" | cat -A } autoload -U add-zsh-hook add-zsh-hook preexec echo_preexec_command ``` Now if I type `echo \b` the string `echo ^H$` is printed (i.e. `\b` was replaced by `^H`). This does not happen when using `fc -nl -1`. How can I get the same inside `preexec`? Thanks! ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Getting the command in preexec as precisely typed 2019-06-02 14:45 Getting the command in preexec as precisely typed Sylvia Gough @ 2019-06-02 16:03 ` Sebastian Gniazdowski 2019-06-02 21:22 ` Sylvia Gough 0 siblings, 1 reply; 5+ messages in thread From: Sebastian Gniazdowski @ 2019-06-02 16:03 UTC (permalink / raw) To: Sylvia Gough; +Cc: Zsh Users On Sun, 2 Jun 2019 at 16:47, Sylvia Gough <q0h8xdveje@gmail.com> wrote: > ... > Now if I type `echo \b` the string `echo ^H$` is printed (i.e. `\b` was > replaced by `^H`). > This does not happen when using `fc -nl -1`. > > How can I get the same inside `preexec`? > > Thanks! It is the echo in the hook that does the conversion \b -> ^H. Use -E option with echo to prevent this. -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Getting the command in preexec as precisely typed 2019-06-02 16:03 ` Sebastian Gniazdowski @ 2019-06-02 21:22 ` Sylvia Gough 2019-06-03 9:26 ` Roman Perepelitsa 0 siblings, 1 reply; 5+ messages in thread From: Sylvia Gough @ 2019-06-02 21:22 UTC (permalink / raw) To: Sebastian Gniazdowski; +Cc: Zsh Users [-- Attachment #1: Type: text/plain, Size: 676 bytes --] Thanks, that works! On Sun, Jun 2, 2019 at 7:03 PM Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote: > On Sun, 2 Jun 2019 at 16:47, Sylvia Gough <q0h8xdveje@gmail.com> wrote: > > ... > > Now if I type `echo \b` the string `echo ^H$` is printed (i.e. `\b` was > > replaced by `^H`). > > This does not happen when using `fc -nl -1`. > > > > How can I get the same inside `preexec`? > > > > Thanks! > > It is the echo in the hook that does the conversion \b -> ^H. Use -E > option with echo to prevent this. > > -- > Sebastian Gniazdowski > News: https://twitter.com/ZdharmaI > IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin > Blog: http://zdharma.org > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Getting the command in preexec as precisely typed 2019-06-02 21:22 ` Sylvia Gough @ 2019-06-03 9:26 ` Roman Perepelitsa 2019-06-03 9:39 ` Sylvia Gough 0 siblings, 1 reply; 5+ messages in thread From: Roman Perepelitsa @ 2019-06-03 9:26 UTC (permalink / raw) To: Sylvia Gough; +Cc: Sebastian Gniazdowski, Zsh Users When printing content outside of your control, use `print -r -- $1` or `echo -E - $1`. Plain `echo -E $1` won't work if the argument is `-n` or some other valid flag. Roman. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Getting the command in preexec as precisely typed 2019-06-03 9:26 ` Roman Perepelitsa @ 2019-06-03 9:39 ` Sylvia Gough 0 siblings, 0 replies; 5+ messages in thread From: Sylvia Gough @ 2019-06-03 9:39 UTC (permalink / raw) To: Roman Perepelitsa; +Cc: Sebastian Gniazdowski, Zsh Users [-- Attachment #1: Type: text/plain, Size: 296 bytes --] Good point, thanks! On Mon, Jun 3, 2019 at 12:26 PM Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote: > When printing content outside of your control, use `print -r -- $1` or > `echo -E - $1`. Plain `echo -E $1` won't work if the argument is `-n` > or some other valid flag. > > Roman. > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-03 9:40 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-06-02 14:45 Getting the command in preexec as precisely typed Sylvia Gough 2019-06-02 16:03 ` Sebastian Gniazdowski 2019-06-02 21:22 ` Sylvia Gough 2019-06-03 9:26 ` Roman Perepelitsa 2019-06-03 9:39 ` Sylvia Gough
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).