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

_dispatch (was Re: PATCH: [for consideration] TMPSUFFIX)



On Sep 28, 10:24am, Daniel Shahaf wrote:
} Subject: Re: PATCH: [for consideration] TMPSUFFIX
}
} Bart Schaefer wrote on Tue, Sep 27, 2016 at 12:20:50 -0700:
} > there was not that too much code was aborted, rather that because of a
} > surrounding use of "eval" not *enough* code was aborted; a scripting
} > error.
} 
} What can we do to cause enough code to be aborted in that case?  Perhaps
} something like the following:
} 
} +  {
} +    eval "$comp" && ret=0
} +  } always {
} +    if (( TRY_BLOCK_ERROR )); then
} +      ... throw the exception ... 
} +    fi
} +  }

Sadly, that won't do it either -- TRY_BLOCK_ERROR is not set:

[[[
torch% comp=': ${:}'
torch% { eval "$comp" && print OK } always { print $TRY_BLOCK_ERROR }
zsh: unrecognized modifier
0
torch% print $?
1
torch% comp=': *(#q)(#q)'                                           
torch% { eval "$comp" && echo OK } always { print $TRY_BLOCK_ERROR }
zsh: unknown file attribute: #
0
]]]

The eval captures everything and turns it into nonzero exit status.

The eval is there (and in two other places in _dispatch) because one
can pass a command line as the first argument of compadd:

    compdef 'compadd *' f

There might be another way to permit that without eval'ing, but it
would be convoluted.



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