Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: trap question



On Fri, Nov 25, 2022 at 7:36 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> So what I'm really wanting is some way to set the trap in such a
> way that it responds to the value of 'var' *at the time of the springing
> of the trap*, namely at 'return'.  Can it be done?

Try replacing this:

    trap " [[ $var == '0' ]] && echo trap: var is: $var" EXIT

with this:

    trap ' [[ $var == 0 ]] && echo trap: var is: $var' EXIT

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author