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

Re: trap question




On 2022-11-25 10:57, Roman Perepelitsa wrote:
Try replacing this:
     trap " [[ $var == '0' ]] && echo trap: var is: $var" EXIT

with this:

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

Bullseye.  And I understand it I think.  Double quotes evaluated when parsed, single quotes kept as literal until trap is sprung, yes?  It 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?  BTW, will this trap catch exiting errors or just proper returns?  I know it doesn't catch ^C.






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