[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: some string issue inside cmd not found handle
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: some string issue inside cmd not found handle |
Date: |
Sat, 6 Nov 2021 19:09:05 +0100 |
On Sat, Nov 6, 2021, 19:04 Lawrence Velázquez <vq@larryv.me> wrote:
> 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
>
i do this cause it only goes maxdepth 1, if i enter foo/nonexist it wont
open
sad
>
> > 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.
>
yes thats definately teh solution
thank you
>
> bash-5.1$ command_not_found_handle() { printf '<%s>\n' "$@"; }
> bash-5.1$ foo a b c
> <foo>
> <a>
> <b>
> <c>
>
> --
> vq
>