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

Re: why not promote the plague ? (brace|rc|alternative|modern) syntax



On Mon, Dec 16, 2024, at 4:16 AM, Marc Chantreux wrote:
> On Sat, Dec 14, 2024 at 06:36:51PM -0500, Lawrence Velázquez wrote:
>> sublists, which POSIX calls AND-OR lists.  For example, this:
>
> To me this is weird because it means punctuations are not treated
> the same way: \n ; | && || should be treated equally

I don't know what you mean by this.


> in zsh (AFAIU) it's not consistant with the function declaration:
>
> 	foo() hostname && hostname
> 	echo tadaaaa:
> 	hostname
>
> 	# prometheus
> 	# tadaaaa:
> 	# prometheus
>
> 	if {true} hostname && hostname
> 	echo tadaaaa:
>
> 	# prometheus
> 	# prometheus
> 	# tadaaaa:

That's right; the Bourne-style function definition syntax only
permits the body to be a command, not any sort of list (except
within a compound command).  That leads to this fun comparison:

	% setopt SHORT_LOOPS
	% f() print abc && print xyz; f
	xyz
	abc
	% function g; print abc && print xyz; g
	abc
	xyz

Yet another asterisk.


-- 
vq




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