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

Re: ${name:?word} get executed though -n specified



On Fri, 01 Jul 2011 10:41:07 +0100, hanpingtian <hanpingtian@xxxxxxx> 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@xxxxxxx>                  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



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