help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is it normal that $BASH_COMMAND doesnt contain func() definition cmd


From: Kerin Millar
Subject: Re: is it normal that $BASH_COMMAND doesnt contain func() definition cmds ? then its just ( again ? ) the last cmd before foo() def
Date: Fri, 30 Jun 2023 02:23:25 +0100

On Fri, 30 Jun 2023 01:34:43 +0200
alex xmb ratchev <fxmbsw7@gmail.com> wrote:

> im working on a multiline prompt
> i use $BASH_COMMAND there
> 
> the line before the numbers and PWD is bash_cmd
> 
> foo() : and complete foo() dont appear
> i just wanna say thats a buggy loss
> 
> type foo
> bash: type: foo: not found
> 
> type foo
> 1 10216 10216 10216 /data/data/com.termux/files/home
> foo() :
> bash: syntax error near unexpected token `:'

Given that the input could not be parsed, it's unreasonable to expect it to 
qualify as a "command currently being executed or about to be executed". It is 
neither of those things.

> 
> type foo
> 2 10216 10216 10216 /data/data/com.termux/files/home
> foo() { : ; }

Apparently, a function declaration doesn't count as a command. If you actually 
proceed to call the function, the : command will be saved to BASH_COMMAND 
because it's the last simple command to be executed within your { list; }.

-- 
Kerin Millar



reply via email to

[Prev in Thread] Current Thread [Next in Thread]