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

Regression / err_return / arithmetic 5.4.x ?



Folks,

A function I use has stopped working on the box with zsh 5.4.2 installed
but still works on 5.3.1.  It looks as though the impact of a false
arithmetic return in the control for a while loop is causing early
function return instead of being considered "handled" by being part of
the control structure.

The function is called "arin" and is one of a bunch of
autoloads-via-symlink which reference a common "xwhois" function.

--------------------------8< whence -f arin >8--------------------------
arin () {
	setopt local_options warn_create_global err_return no_unset
#...
	local -i loop=1
	while ((loop--))
	do
		case $cmd in
#...
			(arin|arinwhois) registry=whois.arin.net  ;;
		esac
	done
	$whois -h $registry -- "${override_args:-}$*" | less -FXM
}
--------------------------8< whence -f arin >8--------------------------

---------------------------8< fail: 5.4.2 >8----------------------------
% whence -v ztrace{
ztrace{ is an alias for () { setopt localoptions xtrace;
% ztrace{ arin 192.0.2.1 }
+(anon):0> arin 192.0.2.1
+arin:4> setopt local_options warn_create_global err_return no_unset
+arin:6> local cmd=arin
+arin:7> local whois=''
+arin:8> local registry
+arin:9> local override_args
+arin:10> local f
+arin:11> f=whois
+arin:13> [[ -x /usr/bin/whois ]]
+arin:14> whois=/usr/bin/whois
+arin:15> break
+arin:19> [[ -z /usr/bin/whois ]]
+arin:24> local -i loop=1
+arin:25> (( loop-- ))
+arin:27> case arin (xwhois)
+arin:27> case arin (ripe|ripewhois)
+arin:27> case arin (testripe|testripewhois)
+arin:27> case arin (org|orgwhois)
+arin:27> case arin (core|corewhois)
+arin:27> case arin (arin|arinwhois)
+arin:46> registry=whois.arin.net
+arin:25> (( loop-- ))
---------------------------8< fail: 5.4.2 >8----------------------------

Return status from that function is 1.

On 5.3.1, the same invocation adds:

-----------------------8< success extra: 5.3.1 >8-----------------------
+arin:64> /usr/bin/whois -h whois.arin.net -- 121.42.217.44
+arin:64> less -FXM
-----------------------8< success extra: 5.3.1 >8-----------------------

I can remove the err_return safety check, but this looks like a
regression, so I'm reporting it.

5.3.1% zsh -fc 'setopt err_return;(){ local -i l=3; while ((l--)) { echo ": $l" }; echo done }; echo $?'
: 2
: 1
: 0
done
0
5.3.1%


5.4.2% % zsh -fc 'setopt err_return;(){ local -i l=3; while ((l--)) { echo ": $l" }; echo done }; echo $?'
: 2
: 1
: 0
1
5.4.2%



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