[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: some string issue inside cmd not found handle
From: |
Lawrence Velázquez |
Subject: |
Re: some string issue inside cmd not found handle |
Date: |
Sat, 06 Nov 2021 14:03:21 -0400 |
User-agent: |
Cyrus-JMAP/3.5.0-alpha0-1369-gd055fb5e7c-fm-20211018.002-gd055fb5e |
On Sat, Nov 6, 2021, at 2:41 AM, Alex fxmbsw7 Ratchev wrote:
> cat function/command_not_found_handle
> m "$BASH_COMMAND"
>
> type m
> m is aliased to `vim'
>
> type command_not_found_handle
> command_not_found_handle is a function
> command_not_found_handle ()
> {
> vim "$BASH_COMMAND"
> }
lmao so you're going to go ahead and do this anyway, incredible
> foo
> # vim opens, with the bash cmd as arg ( threated as filename )
>
> "vim "$BASH_COMMAND"" [New] 0,0-1
> All
Do you expect BASH_COMMAND to have the value of the original command?
It only works that way within traps. `command_not_found_handle`
isn't a trap.
bash-5.1$ command_not_found_handle() { declare -p BASH_COMMAND; }
bash-5.1$ foo
declare -- BASH_COMMAND="declare -p BASH_COMMAND"
This is the same behavior you'd see outside of `command_not_found_handle`.
bash-5.1$ declare -p BASH_COMMAND
declare -- BASH_COMMAND="declare -p BASH_COMMAND"
Maybe try using the positional parameters instead.
bash-5.1$ command_not_found_handle() { printf '<%s>\n' "$@"; }
bash-5.1$ foo a b c
<foo>
<a>
<b>
<c>
--
vq