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

Re: Accessing the evaluated expression which caused an error



On Sat, Sep 4, 2021 at 5:27 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> Will the (e) actually evaluate the parameters and execute them again? Or just a single layer of expansion?

Well ... it only does a single layer, but the string value of
ZSH_DEBUG_CMD is not itself specially quoted, so you only want to
apply (e) to cases like "${cmd[@]}" where you've deliberately added an
extra layer of quoting and want to peek inside it.

Then of course you probably want to put the quoting back again ... I
guess it ends up something like:

TRAPDEBUG() {
  if function {
    setopt localoptions extendedglob
    [[ $ZSH_DEBUG_CMD = \"[^\"](#c1,)\" ]]
  }
  then ZSH_DEBUG_CMD=${(@q-)${(z)${(e)${(Q)ZSH_DEBUG_CMD}}}}
  fi
  print -r -- $ZSH_DEBUG_CMD
}




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