Comment on Yes
MonkderZweite@feddit.ch 11 months ago
Just don’t call it with ‘!#/bin/sh’. Because that’s POSIX shell, not bash.
Comment on Yes
MonkderZweite@feddit.ch 11 months ago
Just don’t call it with ‘!#/bin/sh’. Because that’s POSIX shell, not bash.
philm@programming.dev 11 months ago
but effectively it’s bash, I think
/bin/sh
is a symlink to bash on every system I know of…MonkderZweite@feddit.ch 11 months ago
Still don’t do this. If you use bash specific syntax with this head, that’s a bashism and causes issues with people using zsh for example. Or with Debian/*buntu, who use dash as init shell.
wolo@lemmy.blahaj.zone 11 months ago
#!/bin/bash
doesn’t work on NixOS since bash is in the nix store somewhere,#!/usr/bin/env bash
resolves the correct location regardless of where bash isJackbyDev@programming.dev 11 months ago
Are there any distos with
/use/bin/env
in a different spot? I still believe that’s the best approach for getting bash.quantenzitrone@feddit.de 11 months ago
/bin/bash
won’t work on every system for example NixOS some other systems may have bash in /usr/bin or elsewhereMonkderZweite@feddit.ch 11 months ago
NixOS didn’t do /usr merge?
JackbyDev@programming.dev 11 months ago
No no no no no, do not believe this you will shoot yourself in the foot.
wiki.debian.org/Shell
SurpriseWaterfall@sopuli.xyz 11 months ago
It is a symlink, but bash will automatically enable posix compliance mode if you use it. So any bash specific features will bomb out unless you explicitly reset it in the script.
UNWILLING_PARTICIPANT@sh.itjust.works 11 months ago
Wut that is not even the case for Ubuntu. You’re probably thinking of
dash
example:callyral@pawb.social 11 months ago
i thought most unix-like systems had it symlinked to a shell like
dash
. it’s what i have on my system.i use
#!/bin/sh
for posix scripts and#!/usr/bin/env bash
for bash scripts.#!/bin/sh
works for posix scripts since even if it’s symlinked to bash, bash still supports posix features.Aatube@kbin.social 11 months ago
macOS
Debian
Ubuntu