Skip to content

feat: add shebang support to scripts #10134

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

Merged
merged 1 commit into from
Oct 9, 2023
Merged

feat: add shebang support to scripts #10134

merged 1 commit into from
Oct 9, 2023

Conversation

kylecarbs
Copy link
Member

This enables much greater portability!

@kylecarbs kylecarbs requested a review from mafredri October 9, 2023 14:14
@kylecarbs kylecarbs self-assigned this Oct 9, 2023
This enables much greater portability!
@kylecarbs kylecarbs force-pushed the shebang branch 2 times, most recently from 4f7c84b to bae3a1e Compare October 9, 2023 14:44
@kylecarbs
Copy link
Member Author

@mafredri going to merge this, but feel free to review post and I'll address anything!

@kylecarbs kylecarbs merged commit b402f2a into main Oct 9, 2023
@kylecarbs kylecarbs deleted the shebang branch October 9, 2023 15:57
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2023
} else {
args = []string{}
}
args = append(args, caller, script)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess this still assumes that the shebang is for a shell that supports -c or /c.

What if this was the contents:

#!/usr/bin/env node

console.log('hi');

This works on a typical Unix system, but here it would trigger the --check flag for node. I suppose to truly replicate shebang, we should also write script to a file as-is, so that we can then call this via (name, args..., "/path/to/script").

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this gets a bit weird but we totally can. Should we just temporarily write it then defer a cleanup?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, a bit weird, but it'd be awesome to support the use-case fully. I think temp write + cleanup sounds good (and no need to make it executable since we're handling the shebang parsing part)!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Going to fix!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants