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

Re: Bug in test scripts "q" flag



Bart Schaefer wrote on Fri, 07 Nov 2025 23:57 +00:00:
> Ignore for the moment the bug (?) that
>   () { typeset -n x='$[1]'; print $x }
> prints nothing instead of printing the first digit of $$.  The bug for
> purposes of this post is that the blank line output by
>   print -r $x
> does not match the output spec when the "0q" is used.
⋮
> Here, "q" expands $nothing to, well, nothing, and thereby keeps the
> final line of the expected output and successfully matches the blank
> line from the final "print".  It would be preferable if the former
> spec were usable, but I'm not sure what in ztst.zsh to change to
> preserve the line.

Possibly the «substlines="$(<$ZTST_out)"» on line 525?  It's the only
place where the presence of q affects the handling of expected output
lines, and the $(…) could be removing final empty lines.

At that point, ZTST_out and ZTST_tout are respectively the expected and
actual output (judging by the "ZTST_verbose 2" print just above and the
diff(1) call just below).

This also suggests that adding "echo non-empty final line to work around
a test harness bug" to the test code might be a workaround.

HTH,

Daniel

> Un-ignoring the x='$[1]' bug again, I may in the final analysis
> instead add the "f" flag like so:
>
> ###
>  edgecase \$; edgecase '$[1]'
> 0qf:references to $$
>>typeset -n x='$'
>>$$
>>typeset -n x='\$[1]'
>>$$[1]
> ###
>
> Just in case it does end up fixed at some point.




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