I take my shitposts very seriously.

  • 1 Post
  • 4 Comments
Joined 3 years ago
cake
Cake day: June 24th, 2023

help-circle
  • It follows the same convention as most programming languages that expose the argument list. Python’s sys.argv has the program name at index 0 and the first argument at index 1. C’s char **argv does the same: index 0 is the program name, index 1 is the first argument. So it stands to reason that Zsh’s $0 should be the program name and $1 should be the first argument…

    …which, by the way, is exactly what Bash does as well.


  • That isn’t incorrect, but it’s not as important as people make it out to be. Linux isn’t certified as POSIX-conformant either.

    People are way too stuck on POSIX regarding Fish specifically, but in shell scripting, POSIX compliance boils down to “can it run a pure sh script”. Bash is compliant. Zsh is partially compliant and needs to set an option to emulate sh. Fish uses a different syntax and is not compliant; if that is a problem, don’t execute sh scripts in Fish.

    POSIX compliance for shell scripts was important in the 80s and 90s when the #! directive wasn’t as commonly implemented and every script might be executed by the user’s $SHELL instead. That is no longer the case as virtually every Unix-like system’s program loader supports #!.