Ruud H.G. van Tol on Sun, 26 Dec 2021 00:24:16 +0100


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

Re: shebang line, gives syntax error



On 2021-12-25 19:53, Bill Allombert wrote:
On Sat, Dec 25, 2021 at 05:54:40PM +0100, Ruud H.G. van Tol wrote:

I have put a shebang-line
in the very first line of
a .gp file, like:

#!/usr/local/bin/gp

When I let that file run itself,
it mentions:

parisize = 8000000, primelimit = 500000, nbthreads = 8
   ***   syntax error, unexpected '/': #!/usr/local/bin/gp
   ***                                   ^-----------------
... skipping file '<redacted>.gp'

How to make gp ignore that shebang-line?

Sorry, I do not know anyway to do that, and the shebang-line allows for
a single option anyway

One way is

# /bin/sh
gp -f -q -D output=0 << 'EOF'
...
...
...
EOF

THe only way I see to fix that would be to hande
#!/ as the start of the line as a comment.

Also at the start of the very first line,
with no leading whitespace.

The regex could then be: /\A#!.*/
(if found at start of buffer, to treat as comment)

The "trick" I used for the workaround:
/\A#![a-z]+/, is not a syntax error,
so that can (probably very theoretically)
cause backward-compatibility-issues.

-- Ruud