about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/init.c8
-rw-r--r--Test/A01grammar.ztst4
3 files changed, 14 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5fc193d56..3d24e69ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-04-11  Peter Stephenson  <pws@csr.com>
+
+	* 21131: Src/init.c, Test/A01grammar.ztst: exit with status 127
+	when a script is not found, making the error message more
+	sensible.
+
 2005-04-10  Clint Adams  <clint@zsh.org>
 
 	* unposted: config.guess, config.sub: update to 2005-03-24 and
diff --git a/Src/init.c b/Src/init.c
index 965f47174..b9658af63 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -308,14 +308,14 @@ parseargs(char **argv)
     }
     if (*argv) {
 	if (unset(SHINSTDIN)) {
-	    argzero = *argv;
 	    if (!cmd)
-		SHIN = movefd(open(unmeta(argzero), O_RDONLY | O_NOCTTY));
+		SHIN = movefd(open(unmeta(*argv), O_RDONLY | O_NOCTTY));
 	    if (SHIN == -1) {
-		zerr("can't open input file: %s", argzero, 0);
-		exit(1);
+		zerr("can't open input file: %s", *argv, 0);
+		exit(127);
 	    }
 	    opts[INTERACTIVE] &= 1;
+	    argzero = *argv;
 	    argv++;
 	}
 	while (*argv)
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 15df464e0..093ef5635 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -452,3 +452,7 @@
   $ZTST_testdir/../Src/zsh -f -c "'"
 1:Parse error on inline command causes non-zero exit status
 ?zsh: unmatched '
+
+  $ZTST_testdir/../Src/zsh -f NonExistentScript
+127q:Non-existent script causes exit status 127
+?$ZTST_testdir/../Src/zsh: can't open input file: NonExistentScript