eraserhd / parinfer-rust

A Rust port of parinfer.
ISC License
546 stars 42 forks source link

Guile shebang is rejected due to \ #100

Closed aecepoglu closed 3 years ago

aecepoglu commented 3 years ago

I have guile scripts I use as CLI programs which have shebangs like so:

#! /usr/local/bin/guile \
-e main -s
!#
(define (main args)
  (write args)
  (newline))

https://www.gnu.org/software/guile/manual/html_node/Command-Line-Handling.html

This syntax isn't supported by parinfer-rust because it doesn't like \ in line ends.

Is this intended?

eraserhd commented 3 years ago

I definitely want to support this case.

It looks like we support lisp block comments starting with #| but not #!, and we don't have any special handling of the first two characters of the file.

In addition, Guile appears to be unique in ignoring up until a closing !#:

So, I propose:

And maybe:

mnacamura commented 3 years ago

Another example of multiline shebang in a Scheme implementation:

#!/bin/sh
:; exec gosh -- $0 "$@"

See Gauche manual sec. 3.3.

EDIT: This shebang is single line! I could not be aware of the slick technique. Sorry to bother you.

aecepoglu commented 3 years ago

Thanks :)