* Changing rc to understand about shell scripts with no magic number
@ 1991-06-30 12:35 Solid Hogan
0 siblings, 0 replies; only message in thread
From: Solid Hogan @ 1991-06-30 12:35 UTC (permalink / raw)
To: The Rc Mailing List
On most systems there are many shell scripts without the #! magic number.
These are supposed to be interpreted by /bin/sh; their authors assumed
that this would automatically happen.
Under rc, however, something different happens. If you were to attempt to
run, for instance, clear, on our system you would get:
clear: Exec format error
The following patch to exec.c detects the ENOEXEC error, and runs /bin/sh
on the offending file:
*** exec.c.old Sun Jun 30 22:17:04 1991
--- exec.c Sun Jun 30 22:16:20 1991
***************
*** 6,11 ****
--- 6,12 ----
#include <setjmp.h>
#include <signal.h>
+ #include <sys/errno.h>
#include "rc.h"
#include "utils.h"
#include "exec.h"
***************
*** 98,103 ****
--- 99,119 ----
rc_exit(getstatus());
}
execve(path, (char **)av, (char **)ev); /* bogus, huh? */
+ if (errno == ENOEXEC)
+ {
+ char **av2;
+ int num, i;
+
+ num = listnel(s);
+ av2 = (char **) nalloc((num + 2) * sizeof (char *));
+ for (i = 1; i <= num; i++)
+ av2[i+1] = av[i];
+ av2[0] = av[0];
+ av2[1] = path;
+ execve("/bin/sh", (char **)av2, (char **)ev);
+ uerror(*av);
+ rc_exit(1);
+ }
uerror(*av);
rc_exit(1);
/* NOTREACHED */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1991-06-30 14:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-06-30 12:35 Changing rc to understand about shell scripts with no magic number Solid Hogan
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).