[kwlug-disc] Why I Don't Use #!/bin/bash - Shebangs Explained! (Another one by Dave at YSAP)

Jason Eckert jason.eckert at gmail.com
Sun Aug 31 09:50:49 EDT 2025


Somewhat related: If you've ever traced an ancient UNIX or Linux script,
you'd likely see a single colon on the first line instead of a shebang -
this is a shortcut to the true function and guarantees that the script will
run in the current shell, no matter what the calling shell is (e.g., if
you're in zsh and you run "bash script1.sh", it would still run in zsh if
the script started with a ":" line). It's one of those things that are
incredibly useful the few times you need it (and I've used it many times
over the years).

On Sun, 31 Aug 2025 at 01:59, Ron <ron at bclug.ca> wrote:

>
> It's a long weekend, a good time to play in the garden, ride bicycles up
> and down hills, and watch some `bash` videos.
>
>
> Dave at YSAP discusses "shebang" lines and does his deep-dive into them.
>
>
> Shebang lines are those lines at the top of a script that bash
> processes, right?
>
> Wrong. Bash ignores that line, it's the kernel that processes the shebang.
>
> Node / v8 also are smart enough to ignore the shebang line, even though
> lines starting with # in JS are *not* comments.  Cool!
>
>
>
> He compares behaviours on Darwin, Void Linux, and IllumOS / SunOS.
>
> Differences show up when passing options in shebang lines.
>
>
>
> Lots of interesting tricks can be had by tweaking that line, and after
> some 10 minutes of general explanation, he heads down the rabbit hole
> starting with his favourite distro, Void Linux.
>
>
> > https://www.youtube.com/watch?v=aoHMiCzqCNw
>
>
> TL;DR:
>
> use:
>
> #!/usr/bin/env bash
>
> (or, since I'm a new convert)
>
> #!/usr/bin/env fish
>
>
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
> with the subject "unsubscribe", or email
> kwlug-disc-owner at kwlug.org to contact a human being.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20250831/a3d6cc65/attachment.htm>


More information about the kwlug-disc mailing list