[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should es do this?



[i forwarded this to the list because i thought that there might be general
interest;  the current design was worked out by me, Byron, and Arnold Robbins
when Arnold posed basically the same question.]

> At the moment es doesn't recognise scripts without magic numbers as being
> executable. Is this the intended behaviour or a machine dependent bug?

default behavior of es is that if something is not executable by the kernel,
it is not executable.  however, when an execve(2) call fails in a child,
the function %exec-failure, is called.  (see the manual for details.)

if your kernel does not support #! magic numbers, define KERNEL_POUNDBANG
as 0 when compiling and there will be a default %exec-failure function
which knows about #!.

if you want sh-style behavior, try something like

        fn %exec-failure file argv0 args {
                exec /bin/sh $file $args
        }

this passes any executable file that the shell finds to /bin/sh.  if you
think, instead, that es should try to exec everything, you could do

        fn %exec-failure file argv0 args {
                . $file $args
        }

if you think that there is any chance that KERNEL_POUNDBANG is defined
on any of the machines you are using, the definition should be something
like

	if {~ $#fn-%exec-failure 0} {
		fn %exec-failure file argv0 args {
			exec /bin/sh $file $args
		}
	} {
		let (old = $fn-%execfailure) {
			fn %exec-failure file argv0 args {
				$old $file $arv0 $args
				exec /bin/sh $file $args
			}
		}
	}

paul