Email or username:

Password:

Forgot your password?
Rubikoid

What the actual fuck.

MacOS (XNU?) just ignores anything after `#` in shebangs.

simpe check:

`args.sh`:
```shell
#!/usr/bin/env sh
echo "\$0 is '$0'"

i=1
for arg in "$@"; do
echo "\$$i is '$arg'"
i=$((i+1))
done

uname -a
```

```shell
#!/usr/bin/env -S ./args.sh test#after
```

(wtf mastodon-glitch, where is my markdown button)

$0 is './args.sh'
$1 is '"test'
$2 is './t.sh’

Darwin rubi-mbpl4 23.5.0 Darwin Kernel Version 23.5. ). Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121. 3~5/RELEASE_ARM64_T6000 armoe4 arm Darwin
$0 is './args.sh'
$1 is 'test#after'
$2 is './t.sh’

Linux kubic 6.6.33 #1-NixOS SMP PREEMPT_DYNAMIC Wed Jun 12 09:13:03 UTC 2024 x86_64 GNU/Linux
2 comments
Rubikoid

Even more fun fact is that this # as EOL thing was introduced specially in XNU.

For the first second I thought this was in *BSD, but I did't found anything related in bsd source code (I was checking 4.3BSD and FreeBSD versions around 3.*)

Some blaming on xnu git[hub] mirror lead me to that.

This conceptual thing was introduced in XNU-517, about 21 years ago, and it's still in kernel.

Go Up