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

Re: PATCH: [for consideration] TMPSUFFIX



Bart Schaefer wrote on Tue, Sep 27, 2016 at 12:20:50 -0700:
> On Sep 27,  7:00am, Daniel Shahaf wrote:
> } Using ERRFLAG_ERROR risks aborting too much code (39154 being a recent
> } example).
> 
> I'm not sure that's really a valid example for this case -- the trouble
> 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:

[[[
diff --git a/Completion/Base/Core/_dispatch b/Completion/Base/Core/_dispatch
index 3f6fe5b..8c5220f 100644
--- a/Completion/Base/Core/_dispatch
+++ b/Completion/Base/Core/_dispatch
@@ -60,7 +60,13 @@ done
 
 if [[ -n "$comp" && "$name" != "${argv[-1]}" ]]; then
   _compskip=patterns
-  eval "$comp" && ret=0
+  {
+    eval "$comp" && ret=0
+  } always {
+    if (( TRY_BLOCK_ERROR )); then
+      ... throw the exception ... 
+    fi
+  }
   [[ "$_compskip" = (all|*patterns*) ]] && return ret
 fi
 
]]]

where the ellipsis throws the exception that occurred in the 'eval'.

(Sidebar: if errflag ever had the ERRFLAG_HARD bit set but the
ERRFLAG_ERROR bit unset, then $TRY_BLOCK_ERROR would be zero; this can't
currently occur because ERRFLAG_HARD always occurs alongside ERRFLAG_ERROR..)

> } A middle way would be to force the simple command that =(:) was part to
> } return 127.
> 
> If we were to parallel other redirection errors, the command should
> just return 1.  Otherwise I'd say we should report the actual error
> number instead of always 127. 

Agreed.  (My bad for being unclear: I said "127" but I meant "non-zero".)

> However, I don't see any obvious way to do either of those things from
> inside stringsubst().



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