On 11/04/2021 17:09, shwaresyst via austin-group-l at The Open Group wrote:
No, it's not nonsense. The definition of comment has all characters, including '!', shall be ignored until newline or end-of-file being conforming. Then tokenization which might discover an operator, keyword or command continues. This precludes "#!" being recognized as any of those. There is NO allowance for '!' being the second character as reserved for implementation extensions.

This is wrong on two counts. The first is that you're assuming that this will be interpreted by a shell. If execve() succeeds (and the #! line does not name a shell), it will not be interpreted by a shell at all, and the shell syntax for comments is irrelevant. The second is about what happens when it does get interpreted by a shell: POSIX allows shells to treat files starting with "#!" specially: "If the first line of a file of shell commands starts with the characters "#!", the results are unspecified."

Cheers,
Harald van Dijk

      • Re: [Shell C... Harald van Dijk via austin-group-l at The Open Group
      • Re: [Shell C... Robert Elz via austin-group-l at The Open Group
        • Re: [She... Harald van Dijk via austin-group-l at The Open Group
          • Re: ... Joerg Schilling via austin-group-l at The Open Group
        • Re: [She... Robert Elz via austin-group-l at The Open Group
          • Re: ... Harald van Dijk via austin-group-l at The Open Group
          • Re: ... Robert Elz via austin-group-l at The Open Group
        • Re: [She... Joerg Schilling via austin-group-l at The Open Group
  • Re: [Shell Command La... Robert Elz via austin-group-l at The Open Group
    • Re: [Shell Comma... shwaresyst via austin-group-l at The Open Group
      • Re: [Shell C... Harald van Dijk via austin-group-l at The Open Group
        • Re: [She... shwaresyst via austin-group-l at The Open Group
          • Re: ... Harald van Dijk via austin-group-l at The Open Group
          • Re: ... Joerg Schilling via austin-group-l at The Open Group
          • Re: ... Chet Ramey via austin-group-l at The Open Group
        • Re: [She... Robert Elz via austin-group-l at The Open Group
      • Re: [Shell C... Joerg Schilling via austin-group-l at The Open Group
      • Re: [Shell C... Joerg Schilling via austin-group-l at The Open Group
        • Re: [She... shwaresyst via austin-group-l at The Open Group
        • Re: [She... Robert Elz via austin-group-l at The Open Group
          • Re: ... Joerg Schilling via austin-group-l at The Open Group

Reply via email to