* zsh exec format error with empty files
@ 2015-12-23 17:01 Christian Neukirchen
2015-12-25 8:27 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Christian Neukirchen @ 2015-12-23 17:01 UTC (permalink / raw)
To: zsh-workers
Hi,
It is customary for POSIXy shells that executables which result in
format errors are interpreted as /bin/sh shell scripts.
zsh does this too, but it doesnt work for empty files:
zsh 5.2 (x86_64-unknown-linux-gnu)
zsh-5.2-0-gc86c20a
% ls -l empty colon
-rwxrwxr-x 1 chris users 2 Dec 23 17:53 colon*
-rwxrwxr-x 1 chris users 0 Dec 23 17:49 empty*
% cat colon
:
% ./colon
% ./empty
zsh: exec format error: ./empty
For consistency, this should just run /bin/sh as well and return 0,
like in bash, dash, busybox sh, tcsh, mksh, ksh93, posh, Byron's rc
and every tool using execvp.
Happy holidays,
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: zsh exec format error with empty files
2015-12-23 17:01 zsh exec format error with empty files Christian Neukirchen
@ 2015-12-25 8:27 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2015-12-25 8:27 UTC (permalink / raw)
To: zsh-workers
On Dec 23, 6:01pm, Christian Neukirchen wrote:
}
} % ./empty
} zsh: exec format error: ./empty
}
} For consistency, this should just run /bin/sh as well and return 0,
} like in bash, dash, busybox sh, tcsh, mksh, ksh93, posh, Byron's rc
} and every tool using execvp.
Hm.
diff --git a/Src/exec.c b/Src/exec.c
index acc867c..c4dc8e3 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -471,9 +471,10 @@ zexecve(char *pth, char **argv, char **newenvp)
if ((fd = open(pth, O_RDONLY|O_NOCTTY)) >= 0) {
argv0 = *argv;
*argv = pth;
+ execvbuf[0] = '\0';
ct = read(fd, execvebuf, POUNDBANGLIMIT);
close(fd);
- if (ct > 0) {
+ if (ct >= 0) {
if (execvebuf[0] == '#') {
if (execvebuf[1] == '!') {
for (t0 = 0; t0 != ct; t0++)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-25 8:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-23 17:01 zsh exec format error with empty files Christian Neukirchen
2015-12-25 8:27 ` Bart Schaefer
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).