NetBSD-Bugs archive

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

Re: misc/23729 (please add a FAQ on the 'Syntax error: "(" unexpected' ld.so issue)



    Date:        Fri, 17 Jun 2022 15:40:21 +1000
    From:        matthew green <mrg%eterna.com.au@localhost>
    Message-ID:  <6302.1655444421%splode.eterna.com.au@localhost>

  | space-bird ~> /bin/sh /bin/sh
  | /bin/sh: Cannot execute ELF binary /bin/sh

hmmm  ... that looks like  a bug.  If run that way, the shell
should try to run it, just like all the other shells you tried
did.  POSIX does make it undefined/unspecified what happens
when there are any \0's in any part of the script that could be
executed (ie: not counting random data that may followw) so
we are probably technically conformant, but that still seems
wrong.

I will, however, resist fixing it fir a few days to see what
others think.

The issue in the PR (which is not really about this problem
at all) concerns seemingly sane, executable, commands - typically
found via a PATH search, though not always - for which exec()
fails with ENOEXEC - which shells from the ancient past, long before
#! was invented, have always treated as meaning "command is a sh
script", and so simply opened and tried to parse that way.

That is still required by POSIX (which does not have #!), but
they do now permit the shell to use a heuristic to guess
whether the file really is a script or not.

Most shells implement such a test now (but less did when this
PR was filed .. POSIX didn't allow it then) so the problem
reported occurs far less often than it did (it is still not
well handked).

kre


Home | Main Index | Thread Index | Old Index