🤔 Ah yes, the shebang: the arcane sorcery of #Unix that only the truly initiated can understand. This article is a riveting journey through a labyrinth of cryptic #commands, ancient UNIX dialects, and #shell incantations that only the most daring #sysadmins dare to comprehend. 🔮 Spoiler alert: it's mostly a lot of blah blah blah with a sprinkle of #! ✨ for flavor.
https://www.in-ulm.de/%7Emascheck/various/shebang/ #shebang #tech #humor #coding #HackerNews #ngated
The #! magic, details about the shebang/hash-bang mechanism

#!magic, details about the shebang/hash-bang mechanism on various Unix flavours

https://www.in-ulm.de/%7Emascheck/various/shebang/

#HackerNews #shebang #Unix #magic #hashbang #Linux #programming

The #! magic, details about the shebang/hash-bang mechanism

🌘 「#!」魔術:剖析 Unix 雜湊符號/Shebang 機制的細節
➤ 從起源到演變:深入解析 Unix 腳本的「#!」啟動機制
https://www.in-ulm.de/%7Emascheck/various/shebang/
本文深入探討了 Unix 系統中「#!」雜湊符號(Shebang)機制的演變與技術細節。作者追溯了此機制的起源,從貝爾實驗室早期的研究計畫,到各個 Unix 版本(包括 BSD 系列、System III、SVR4 等)的實作演變。文章詳細闡述了「#!」如何讓系統識別並執行指定直譯器來運行腳本,並深入探討了相關議題,如字串長度限制、參數傳遞、安全性考量(尤其是 setuid 腳本的處理)、空白字元的影響,以及跨系統的移植性問題。透過對歷史程式碼和文件紀錄的考證,作者釐清了許多關於「#!」機制的常見迷思與誤解。
+ 這篇文章對於「#!」機制的歷史淵源和技術細節的考證非常到位,很多過去的疑問都解開了!
+ SETUID 腳本的安全性部分講得很清楚,這對開發者來說非常實用。
#Unix #Shebang #雜湊符號 #系統核心 #歷史
The #! magic, details about the shebang/hash-bang mechanism

Chris's Wiki :: blog/unix/ShebangRelativePathSurprise

It's kind of amazing the difference it makes in final #container size when you select the FROM image in your #Dockerfile.

$ podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/doc-preview latest 360b4d419e79 10 seconds ago 436 MB localhost/doc-review/python3.12-alpine latest e05851293725 12 minutes ago 209 MB localhost/doc-review/python-latest latest 5077ac676c94 18 minutes ago 1.28 GB
Originally, I'd started with the
@almalinux "latest" image in #AWS's public ECR registry. However, the python version in it was a bit "off" and had been causing some of the pip modules in my requirements file to not get installed (so I switched to direct-install for those modules). When I submitted my #PullRequest, the reviewer had asked, "why are you doing direct-install for those? The requirements file should take care of that." I'd responded by showing that it hadn't, so the reviewer suggested installing a different version of Python in my container. I thought to myself, "no. I think I'll see if using a less-generic container will work ...and maybe save me some disk real-estate in the process". Initially, I tried using the "python:latest" container as my starting point, but that actually created a fatter image than starting from the Alma Linux one had. So, I dug through the registry to see if there was an image derived from Alpine available (otherwise I'd have switched registries). There was, so I used that. Resulting image was much smaller …but also necessitated updating my #CI script to use /bin/sh since /bin/bash wasn't available (it was a very simple script with no #BASHisms, so changing the script's #SheBang wasn't an issue).

And, yes, I generally prefer to use
#Podman instead of #Docker for my container activities since Podman runs containers in userland.

I always had some here and there issues with shebang in my scripts and I always tried to stick to some rules sometimes without knowing why. I just stumbled upon this nice video that showcases some of the edge cases:

https://youtu.be/aoHMiCzqCNw?si=lFGjwtvFnESH3voj

#shebang #CLI

Why I Don't Use #!/bin/bash - Shebangs Explained!

YouTube

I've been following #YouSuckAtProgramming for a while: https://youtu.be/aoHMiCzqCNw - and I really enjoy the content.

Dave is mainly focusing on  #bash, often digging deep about the topic or command. This one about #shebang is one of those.

Now I know much better 🤪

Why I Don't Use #!/bin/bash - Shebangs Explained!

YouTube

@TheConstructor @khalidabuhakmeh and here is what #roslyn is doing with our file based program https://github.com/dotnet/roslyn/blob/main/docs%2Ffeatures%2Ffile-based-programs-vscode.md

```
produce a C# project XML document in memory, and pass it off to MSBuild. The in-memory project is sometimes called a "virtual project".
```

The #shebang file based program is neat

roslyn/docs/features/file-based-programs-vscode.md at main · dotnet/roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs. - dotnet/roslyn

GitHub
Demystifying the #! (shebang): Kernel Adventures

Clarifying the shebang (#!) mechanism: A step-by-step look using strace and kernel code shows how Linux handles script execution directly, revealing the shell isn't involved initially.

You probably know you can package #python files into a zip file and python will execute it like a script. But did you know that you can put a #shebang line in it?

If `foo.zip` contains `__main__.py` you can do

`echo '#!/usr/bin/python | cat - foo.zip > foo`

and

`chmod u+x foo`

then you can run `foo` like an ordinary program and it will run the contents of `__main__.py`

although I have no idea if you *should* do this.

#bash