today in shell scripting:

if you:
- use `#!/bin/sh` (and not /bin/bash or /usr/bin/env bash), and
- use `echo -n ...` (to say "hey, no newline at the end please)
… you will get "-n" in the output on MacOS.

afaict, i think it's a case of:
- macOS (BSDish), when in /bin/sh, faithfully recreates old /bin/sh echo, which doesn't respect -n.
- the various linuxes do not seem to bother with this, and have -n work the same as it does in bash (often because sh is an alias to bash).

the more u know etc

@buzzyrobin can’t verify on my phone, but this is exactly the kind of thing that I use `shellcheck` to avoid screwing up

@c0dec0dec0de i encountered this within a shell script embedded as a string value in a toml file, but i will take note of this for the future

(the embedded-script-string thing makes sense in context, i swear)

@buzzyrobin GitLab CI embeds bash scripts in YAML. TOML’s taking over for YAML in places. Seems pretty normal to me.

@buzzyrobin Generally this is expected. When calling /bin/sh the shell runs in POSIX mode, also on Linux, and some things behave different. Bash can also be started directly in this mode (https://www.gnu.org/software/bash/manual/bash.html#Bash-POSIX-Mode).

But yes, it looks like "echo -n" works just as expected in this mode. Maybe the behavior of macOS is indeed a result of its FreeBSD roots. Don't know how it behaves there. Is it actually running bash, or some other shell?

Bash Reference Manual

Bash Reference Manual