TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Sbang lets you run scripts with long shebang lines

30 pointsby tgamblinover 4 years ago

7 comments

datasmurfover 4 years ago
I do not think that _this_ was or will be ever an issue to myself or any system that i have to deal with and i do not see any use for it but i guess somebody else did. Anyway I believe this page is a very nice read on the background and a little history <a href="https:&#x2F;&#x2F;www.in-ulm.de&#x2F;~mascheck&#x2F;various&#x2F;shebang&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.in-ulm.de&#x2F;~mascheck&#x2F;various&#x2F;shebang&#x2F;</a>
jeplerover 4 years ago
This reminds me of one of the _very few_ bits of freebsd userspace that are better than gnu and was only adopted by gnu much later (8.30, the version first in debian buster, I think): `env -S`.<p>`env -S` introduces an option parser&#x2F;splitter for #!-lines which can do just about whatever you need (however, it will not work around over-long lines like sbang proposes to do)
评论 #24965104 未加载
评论 #24964424 未加载
wheybagsover 4 years ago
I&#x27;ve never had this problem, what is the use case? I&#x27;ve only ever used &#x2F;usr&#x2F;bin&#x2F;env or &#x2F;bin&#x2F;bash, and can&#x27;t think of a reason to do anything fancier. You would be hardcoding the full (presumably non standard) path to the interpreter right? Why not just add it to PATH and use env?
评论 #24964137 未加载
评论 #24964170 未加载
评论 #24964058 未加载
评论 #24964224 未加载
caymanjimover 4 years ago
Why not just do this:<p><pre><code> #!&#x2F;bin&#x2F;bash &#x2F;some&#x2F;long&#x2F;path with lots of args</code></pre>
评论 #24965307 未加载
评论 #24965152 未加载
stragsover 4 years ago
The problem with shebangs that I really want to solve is that I often need to edit files on a Windows machine, and then try to run the resulting CR&#x2F;LF scripts on a Linux machine using a shared filesystem. (Docker, WSL, Vagrant etc...).<p>I&#x27;d like to invoke them with just (eg.) .&#x2F;dostuff.py - Python, Ruby etc... have absolutely no problem running files containing Win-style line-endings. The only issue is that &#x2F;usr&#x2F;bin&#x2F;env complains that it can&#x27;t find (eg.) &quot;python3\n&quot;.<p>Yes, I know I could convert these files with dos2unix, and I also know that I can just invoke the interpreter explicitly - but I&#x27;m lazy, and this seems like such a trivial thing to solve that I can&#x27;t believe it&#x27;s not been done already.<p>I&#x27;ve taken to actually recompiling &#x2F;usr&#x2F;bin&#x2F;env to strip trailing whitespace from the executable name - but there must be a better solution.
评论 #24964735 未加载
saagarjhaover 4 years ago
I wonder if this could be part of binfmt_misc if Linux let you be the handler for shebangs in general?
评论 #24976306 未加载
eyelidlessnessover 4 years ago
Wouldn’t it be better to standardize format and baseline argument spec, and let the evaluating environment figure out the rest? Formalizing the entry path is something that is now becoming two lines of indirection just to lie to whatever is actually interpreting it. It’s another line of implicit code that’s up to interpretation and can easily diverge.
评论 #24965288 未加载