Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: trap question
On Fri, Nov 25, 2022 at 3:25 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Double quotes evaluated when
> parsed, single quotes kept as literal until trap is sprung, yes?
Yes.
> wouldn't have occurred to me since I'd have expected the '$var' to
> remain un-expandable within single quotes. Is this an exception or
> somehow to be viewed as routine?
You can think of "trap" as a delayed "eval".
> BTW, will this trap catch exiting
> errors or just proper returns?
Depends on the error. If you have "setopt err_exit" (or err_return)
then the trap will be tripped when something returns false, but if you
have "setopt no_unset" (or use ${varname?message}) and reference a
variable that isn't set, the trap will not trip. There are also some
circumstances where the parent shell will have done an opportunistic
"exec" of the final external command, so there's no zsh left to run
the trap (this is technically a bug, and will eventually get fixed).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author