zsh-workers
 help / color / mirror / code / Atom feed
* ${name:?word} get executed though -n specified
@ 2011-07-01  9:41 hanpingtian
  2011-07-01 14:24 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: hanpingtian @ 2011-07-01  9:41 UTC (permalink / raw)
  To: zsh-workers, zsh-users

[-- Attachment #1: Type: text/plain, Size: 285 bytes --]

hey,

I just noticed that even though -n option specified for checking syntax of a script, the ${xxx:?yyy} still gets executed:

[hpt@hpt]/tmp% cat t.sh
#!/bin/zsh
a=${a:?'not set!'}

echo $a
date
[hpt@hpt]/tmp% zsh -n ./t.sh
./t.sh:2: a: 'not set!'
[hpt@hpt]/tmp%

Is this a problem?

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

* Re: ${name:?word} get executed though -n specified
  2011-07-01  9:41 ${name:?word} get executed though -n specified hanpingtian
@ 2011-07-01 14:24 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2011-07-01 14:24 UTC (permalink / raw)
  To: zsh-workers

On Fri, 01 Jul 2011 10:41:07 +0100, hanpingtian <hanpingtian@163.com>  
wrote:
> I just noticed that even though -n option specified for checking syntax  
> of a script, the ${xxx:?yyy} still gets executed:

I think that's a bug.

Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.126
diff -u -r1.126 subst.c
--- Src/subst.c	6 Jun 2011 09:08:21 -0000	1.126
+++ Src/subst.c	1 Jul 2011 14:21:13 -0000
@@ -2715,19 +2715,21 @@
  	case '?':
  	case Quest:
  	    if (vunset) {
-		*idend = '\0';
-		zerr("%s: %s", idbeg, *s ? s : "parameter not set");
-		if (!interact) {
-		    if (mypid == getpid()) {
-			/*
-			 * paranoia: don't check for jobs, but there shouldn't
-			 * be any if not interactive.
-			 */
-			stopmsg = 1;
-			zexit(1, 0);
-		    } else
-			_exit(1);
-		}
+                if (isset(EXECOPT)) {
+                    *idend = '\0';
+                    zerr("%s: %s", idbeg, *s ? s : "parameter not set");
+                    if (!interact) {
+                        if (mypid == getpid()) {
+                            /*
+                             * paranoia: don't check for jobs, but there
+                             * shouldn't be any if not interactive.
+                             */
+                            stopmsg = 1;
+                            zexit(1, 0);
+                        } else
+                            _exit(1);
+                    }
+                }
  		return NULL;
  	    }
  	    break;
Index: Test/E01options.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/E01options.ztst,v
retrieving revision 1.24
diff -u -r1.24 E01options.ztst
--- Test/E01options.ztst	10 Jan 2011 18:24:17 -0000	1.24
+++ Test/E01options.ztst	1 Jul 2011 14:21:13 -0000
@@ -353,6 +353,10 @@
    echo *NonExistentFile*)
  0:NO_EXEC option should not do globbing

+  (setopt noexec
+  echo ${unset_var?Not an error})
+0:NO_EXEC should not test for unset variables
+
    setopt NO_eval_lineno
    eval 'print $LINENO'
    setopt eval_lineno

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070





Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


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

end of thread, other threads:[~2011-07-01 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-01  9:41 ${name:?word} get executed though -n specified hanpingtian
2011-07-01 14:24 ` 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).