zsh-workers
 help / color / mirror / code / Atom feed
* zsh syntax check fails on correct if [[ usage (rhbz 966911)
@ 2013-10-18 14:02 Filip Krska
  2013-10-18 15:33 ` Peter Stephenson
  2013-10-18 15:48 ` Bart Schaefer
  0 siblings, 2 replies; 12+ messages in thread
From: Filip Krska @ 2013-10-18 14:02 UTC (permalink / raw)
  To: zsh-workers

Hello zsh team,

I'd like to report a bug originally filed in 
https://bugzilla.redhat.com/show_bug.cgi?id=966911:

Description of problem:

zsh syntax check fails on simple script, which is syntactically OK, but zsh -n returns 1

Version-Release number of selected component (if applicable):

zsh-4.3.10-5.el6.x86_64

How reproducible:

always

Steps to Reproduce:
1. create a script

$ cat /tmp/test.zsh
#!/bin/zsh

if [[ $# -eq 1 ]]
then
   THE_USER=$1
else
   THE_USER=$(whoami)
fi

2. execute test
$ zsh -n /tmp/test.zsh

3. observe exit value
$ echo $?
1

   
Actual results:

1

Expected results:

0

Additional info:

Upstream zsh-5.0.0, zsh-5.0.2 behaves the same way.

The exitvalue is 0 if we provide exactly one argument:

$ zsh -n /tmp/test.zsh
$ echo $?
1
$ zsh -n /tmp/test.zsh aaa
$ echo $?
0
$ zsh -n /tmp/test.zsh aaa ddd
$ echo $?
1

The exitvalue is 0 if we add one line e.g.:

$ cat /tmp/test.zsh
#!/bin/zsh

if [[ $# -eq 1 ]]
then
   :
   THE_USER=$1
else
   THE_USER=$(whoami)
fi

or if we don't use $(command) construct in `else` branch.


If '[' test instead of '[[' is used, the syntax check returns OK, 
however '[[' syntax is recommended by manual, so the check should work 
as expected for '[[' as well.

Thanks and Regards

Filip

-- 
Filip Krška

GSS-SEG EMEA engineer, #sbr-shells (pri), #sbr-anaconda (sec)
Red Hat Czech s.r.o.
Purkyňova 99/71
612 45, Brno, Czech Republic
email:fkrska@redhat.com
office phone:+420 5322 94499

♡ All Wrongs Reversed
http://copyheart.org


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-11-20 14:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18 14:02 zsh syntax check fails on correct if [[ usage (rhbz 966911) Filip Krska
2013-10-18 15:33 ` Peter Stephenson
2013-10-18 19:12   ` Peter Stephenson
2013-10-18 15:48 ` Bart Schaefer
2013-10-18 15:56   ` Peter Stephenson
2013-10-18 19:20     ` Bart Schaefer
2013-10-18 22:43       ` Peter Stephenson
2013-10-19 21:19         ` Bart Schaefer
2013-10-19 21:46           ` Bart Schaefer
2013-10-19 21:56           ` Peter Stephenson
2013-11-20 14:08             ` Filip Krska
2013-10-18 19:29   ` 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).