• uid0gid0@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      20 hours ago

      It’s the index on 1 that ruins it for me.
      Edit: come to think of it what would zsh print out for echo $0?

      • rtxn@lemmy.worldM
        link
        fedilink
        arrow-up
        1
        ·
        4 hours ago

        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.