On Wed, 15 Jan 2003, Arnaudo Massimo wrote: > * Stoyan Zhekov <zhware / hotpop.com> [marted14 gennaio 2003, alle 09:08]: > > > > > > bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied I have seen this before from bash. I have just dowloaded the bash-2.05b sources and in execute_cmd.c there is the chunk below. I don't know enough to figure out why execve() should fail, but... Hugh #define READ_SAMPLE_BUF(file, buf, len) \ do \ { \ fd = open(file, O_RDONLY); \ if (fd >= 0) \ { \ len = read (fd, buf, 80); \ close (fd); \ } \ else \ len = -1; \ } \ while (0) /* Call execve (), handling interpreting shell scripts, and handling exec failures. */ int shell_execve (command, args, env) char *command; char **args, **env; { struct stat finfo; int larray, i, fd; char sample[80]; int sample_len; SETOSTYPE (0); /* Some systems use for USG/POSIX semantics */ execve (command, args, env); i = errno; /* error from execve() */ SETOSTYPE (1); /* If we get to this point, then start checking out the file. Maybe it is something we can hack ourselves. */ if (i != ENOEXEC) { if ((stat (command, &finfo) == 0) && (S_ISDIR (finfo.st_mode))) internal_error ("%s: is a directory", command); else if (executable_file (command) == 0) { errno = i; file_error (command); } else { /* The file has the execute bits set, but the kernel refuses to run it for some reason. See why. */ #if defined (HAVE_HASH_BANG_EXEC) READ_SAMPLE_BUF (command, sample, sample_len); if (sample_len > 2 && sample[0] == '#' && sample[1] == '!') { char *interp; interp = getinterp (sample, sample_len, (int *)NULL); errno = i; sys_error ("%s: %s: bad interpreter", command, interp ? interp : ""); FREE (interp); return (EX_NOEXEC); } #endif errno = i; file_error (command); } return ((i == ENOENT) ? EX_NOTFOUND : EX_NOEXEC); /* XXX Posix.2 says that exit status is 126 */ }