help-bash
[Top][All Lists]
Advanced

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

Re: How to print the actual command for BASH_COMMAND in trap?


From: Alex fxmbsw7 Ratchev
Subject: Re: How to print the actual command for BASH_COMMAND in trap?
Date: Sun, 13 Jun 2021 12:59:58 +0200

i may have misrembered, by i guess no PS0 in nin interactive yes, ..makes
it only interactive, i didnt test back then non interactive
remember my linker, i used a part only for cmd begin and end displayment
no interactive no go sorry

On Sun, Jun 13, 2021, 12:33 Koichi Murase <myoga.murase@gmail.com> wrote:

> 2021年6月13日(日) 19:09 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>:
> >
> > also maybe check the 'return' trap
> >
> > On Sun, Jun 13, 2021, 12:08 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
> wrote:
> >>
> >> you can, by setting myvar=$BASH_COMMAND in PS0
>
> I doubt you understand the discussion. 1) PS0 is used in interactive
> sessions, but we are talking about non-interactive shell scripts. 2)
> PS0 is not evaluated for trap handlers. 3) How we can set the value of
> variables inside PS0? One cannot directly specify in PS0 the commands
> that will be executed in the main shell. One might do
> PS0='$(myvar=$BASH_COMMAND)', but one cannot see the value in the main
> shell because that happens in the subshell. One may instead do
> PS0='$(echo "$PROMPT_COMMAND" >tmp)' and then read the temporary file
> in the main shell. 4) How do you use `return' trap to obtain the
> current command in trap handlers? Could you show the code?
>
> --
> Koichi
>


reply via email to

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