D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG]Re: writing shell scripts

 

On 25.10.2025 00:45, Dan Dart wrote:
Hello folks

Whilst I agree with the genAI sentiment (don't train it on copyrighted /
permissionless data), I'd just like to point out that when you're writing
*portable* shell scripts for other people, don't do this:

#!/bin/bash
#!/usr/bin/python

as they're not guaranteed to live there. That's what /usr/bin/env is for -
to provide the path to wherever it really does live, and it is much more
likely to exist where you might expect. So:

#!/usr/bin/env bash
#!/usr/bin/env python



This is also good for NixOS, which I believe you use, right Dan? The
amount of times I have to patch shebangs at work on in Nixpkgs to work
with `/usr/bin/env` is relentless.

Thanks for pointing this out!


Best wishes,
--
Dom Rodriguez
--
The Mailing List for the Devon & Cornwall LUG
FAQ: https://www.dcglug.org.uk/faq/