Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shebang workarounds #479

Open
zkat opened this issue Jan 14, 2025 · 2 comments
Open

Shebang workarounds #479

zkat opened this issue Jan 14, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@zkat
Copy link
Member

zkat commented Jan 14, 2025

Discussed in #472

Originally posted by jaxter184 January 9, 2025
I've found KDL to be well-designed to use as a base for a domain-specific scripting language, and shebangs can make scripts more ergonomic to run. Unfortunately, most shebangs are KDL syntax errors (usually because of path separators, but also potentially for other reasons depending on the contents).

I don't think it's a huge deal because the script interpreter can just choose to ignore the first line if it starts with a #! before it passes it into a KDL parser, but my goal in making a discussion about this is to see if anyone's got any better suggestions or examples of this kind of logic being used in the wild. Also, not sure how this kind of workaround would interact with LSPs and syntax highlighters.

There was a mention of shebangs here while discussing a similar syntax: #402, but as far as I can tell, there wasn't an explicit discussion or decision made on whether or not that would be a reasonable thing to do. I wish I had thought about this before the v2 release so they could have maybe been treated as comments (I think that's how the Rust compiler does it?). But such is life.

@zkat zkat added the enhancement New feature or request label Jan 14, 2025
@tabatkins
Copy link
Contributor

I think it would have been good to treat a document-initial (possibly preceded by a bom) #! as a line comment, and would, personally, be ok with still sneaking it in.

In the absence of that, I don't see any ways around it. Either you write a valid KDL document without a shebang, or you write a script where the interpreter knows to discard the shebang. (Or you get "lucky" and write a valid KDL document with a confusing starting node.)

I'm lightly in favor of sucking it up and just issuing v2 errata.

@zkat
Copy link
Member Author

zkat commented Jan 15, 2025

I think that’s why, rather than errata, we could try and do it as part of the IETF RFC, which will likely be slightly different from 2.0.0, and will almost definitely be asked to change by peer reviewers outside of our little community here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants