* spurious 'case' parse error
@ 2017-09-22 14:11 Martijn Dekker
2017-09-22 15:42 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Martijn Dekker @ 2017-09-22 14:11 UTC (permalink / raw)
To: Zsh hackers list
The following causes a spurious parse error in zsh:
case x in
(x)echo ok ;;
esac
Output:
test.zsh:2: parse error near `ok'
The cause is the lack of space after the ')'; that space should be
optional, but is mandatory in zsh.
Interestingly, this works:
case x in
x)echo ok ;;
esac
Confirmed in zsh 5.0.7 through current git. (I didn't test earlier
versions.)
- Martijn
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: spurious 'case' parse error
2017-09-22 14:11 spurious 'case' parse error Martijn Dekker
@ 2017-09-22 15:42 ` Bart Schaefer
2017-09-22 16:59 ` Martijn Dekker
2017-09-23 17:16 ` Peter Stephenson
0 siblings, 2 replies; 4+ messages in thread
From: Bart Schaefer @ 2017-09-22 15:42 UTC (permalink / raw)
To: Martijn Dekker, Zsh hackers list
On Sep 22, 3:11pm, Martijn Dekker wrote:
}
} case x in
} (x)echo ok ;;
} esac
}
} Output:
} test.zsh:2: parse error near `ok'
}
} The cause is the lack of space after the ')'; that space should be
} optional, but is mandatory in zsh.
That's almost certainly happening because
case xecho in
(x|y)echo)echo ok;;
esac
is valid syntax for zsh, so (x)echo is being parsed as a pattern and then
the closing paren is found to be missing.
The space is optional when in sh emulation where grouping syntax is not
allowed in patterns:
Src/zsh --emulate sh
$ case x in
> (x|y)echo ok;;
> esac
echo ok
$
This is probably not going to change, but we'll see what PWS has to say
when he returns from vacation.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: spurious 'case' parse error
2017-09-22 15:42 ` Bart Schaefer
@ 2017-09-22 16:59 ` Martijn Dekker
2017-09-23 17:16 ` Peter Stephenson
1 sibling, 0 replies; 4+ messages in thread
From: Martijn Dekker @ 2017-09-22 16:59 UTC (permalink / raw)
To: zsh-workers
Op 22-09-17 om 16:42 schreef Bart Schaefer:
> That's almost certainly happening because
>
> case xecho in
> (x|y)echo)echo ok;;
> esac
>
> is valid syntax for zsh, so (x)echo is being parsed as a pattern and then
> the closing paren is found to be missing.
That makes sense. Also, when zsh is launched as 'sh', the parsing error
does not occur. Report withdrawn. Sorry for the noise!
- M.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: spurious 'case' parse error
2017-09-22 15:42 ` Bart Schaefer
2017-09-22 16:59 ` Martijn Dekker
@ 2017-09-23 17:16 ` Peter Stephenson
1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2017-09-23 17:16 UTC (permalink / raw)
To: Zsh hackers list
On Fri, 22 Sep 2017 08:42:46 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> That's almost certainly happening because
>
> case xecho in
> (x|y)echo)echo ok;;
> esac
>
> is valid syntax for zsh, so (x)echo is being parsed as a pattern and then
> the closing paren is found to be missing.
Yes, without way too much look ahead we couldn't do anything different
in native mode, but nobody's screaming for that anyway.
> The space is optional when in sh emulation where grouping syntax is not
> allowed in patterns:
>
> Src/zsh --emulate sh
> $ case x in
> > (x|y)echo ok;;
> > esac
> echo ok
> $
Yes, this got fixed up a couple of years ago for increased sh case
compatibility which appears to be doing the right thing so far.
So nothing to do.
pws
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-23 22:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-22 14:11 spurious 'case' parse error Martijn Dekker
2017-09-22 15:42 ` Bart Schaefer
2017-09-22 16:59 ` Martijn Dekker
2017-09-23 17:16 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).