Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: #!/path/to/arch-indep/zsh -f



On Sep 22, 12:24pm, Owen M. Astley wrote:
} Subject: Re: #!/path/to/arch-indep/zsh -f
}
} > Most (I don't know if I can say "all") operating systems won't do two
} > levels of indirection via #! lines.  That is, if the thing on the #!
} > line is not itself a binary in executable format, the OS will not
} > recognize yet another #! line and launch still another interpreter.
} 
} $ <test.sh
} #!/u/pol1b/oma1000/bin/zsh
} 
} echo f
} $ head -n 1 /u/pol1b/oma1000/bin/zsh
} #!/bin/sh -
} $ ./test.sh
} f
} $ reportzsh 
} zsh-3.0.6 dec-alpha-osf4.0
} 
} So not on this system.  

I can't decide if you're agreeing with me or giving a counterexample.

} I thought that most (all) modern operating systems recognise #!
} as a magic number in exec()?

They do, but not necessarily recursively.  Remember that the semantics
of the #! line are to take the name of the interpreter from the line
and run it with the name of the file as its first argument.  If the
interpreter is itself a script with a #!, that would add yet another
first argument, and so on.  The original script file might never have
its contents evaluated at all -- which could be interpreted (sorry) as
a security problem.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author