1. 58
  1. 16

    Today I learned that which isn’t in POSIX. A quick glance at shell history shows I’ve used it 400 odd times in the last 5 years just on my primary desktop machine, nevermind how many places I probably still have it in some random script…

    1. 10

      That’s the power of a good name. I’ve seen “command -v” a few times, but as long as “which” is installed, I’ll be using the name that actually makes sense in the context…

      1. 6
        $ which which
        alias which='command -v'
        

        ;-)

    2. 12

      I’m glad the technical committee eventually overruled the maintainer but the amount of bureaucracy required to get there hints to me that there are lots of other user hostile decisions like this making it into debian packages.

      1. 14

        This bureaucracy makes decision making process more or less predictable. It’s Debian, you know what to expect.

        1. 26

          Yup. One of the big functions of bureaucracy in these cases is to ensure general perceived legitimacy of the outcome. This means both the maintainer being overruled accepting that they had their shot within the context of the process and choosing to continue contributing even though they lost, and the community understanding that the process was fair to those involved and permitted consideration of all relevant sides.

          People sometimes get mad that bureaucracies produce outcomes slowly, but the advantage of this is legitimacy and the stability it provides. Otherwise, the legitimacy of the outcome depends on the degree to which one agrees with the outcome, or trusts / believes in the rightness of the individual or unaccountable group dictating the outcome.

          Kings can make unilateral decisions, but people often don’t like being ruled by kings (open source maintainers probably can’t rely on an equivalent of the divine right).

          1. 7

            People sometimes get mad that bureaucracies produce outcomes slowly, but the advantage of this is legitimacy and the stability it provides. Otherwise, the legitimacy of the outcome depends on the degree to which one agrees with the outcome, or trusts / believes in the rightness of the individual or unaccountable group dictating the outcome.

            Kings can make unilateral decisions, but people often don’t like being ruled by kings (open source maintainers probably can’t rely on an equivalent of the divine right).

            I mean you say that, and then rightfully apply it to statecraft, but I’m pretty sure everyone who has direct experience of say, the UK’s disability welfare processes, understands that there are points at which bureaucracy works counter to stability and legitimacy

            1. 10

              Specific implementations of bureaucracy may not necessarily be made with this goal, but it is the most common goal behind the creation of bureaucratic systems. Similarly, even bureaucratic systems made with this goal in mind may lose sight of this goal or fail to achieve it.

      2. 7

        Didn’t know about command -v before and which not being POSIX either! with that said, and sorry if that’s a stupid question and was already considered and discussed extensively (please kindly disregard then!): could it be possible to just make which be alias/oneliner resolving to command -v and be done with the issue?

        1. 7

          Note sure about the Debian version, but there are a few differences with the FreeBSD one that may matter:

          If you run command -v with a shell builtin then it will print the command name with no path. In contrast, which doesn’t know what builtins your shell supports and so will print the path. This means that you’d get slightly inconsistent output, for example:

          $ which command
          /usr/bin/command
          $ command -v command
          command
          

          I don’t know how much that would matter in practice. The fun thing after that was that actually the stand-alone command binary does have a list of known shell builtins but it appears to be limited to the POSIX set (it doesn’t know what my shell is) and the bash built-in one doesn’t understand backslash-escaping that normally lets you run the stand-alone version instead:

          # Bash knows time is a builtin
          $ command -v time
          time
          # But the system one doesn't
          $ /usr/bin/command -v time
          /usr/bin/time
          # And backslash escaping doesn't seem to make bash run the binary
          $ \command -v time
          time
          

          Again, I don’t know the extent to which scripts depend on this. The last one was interesting to me. I learned that shell builtins and shell keywords are in some way different.

          The other minor issue is that which has arguments (at least on FreeBSD). -a prints all locations of a thing, -s doesn’t print output it just sets the return status. These could both be handled by a shell function, but they’re not quite one liners.

          1. 3

            As someone who wrote a which for laughs once, GNU which actually supports having something feed it built-ins via stdin. I didn’t bother with that and mine is basically somewhere around FreeBSD’s feature wise.

          1. 4

            The which command is a broken heritage from the C-Shell and is better left alone in Bourne-like shells.

            That’s enough for me! Burn the which!

            1. 2

              Am I the only (t)csh user around here?? 8-)

              1. 4

                I am sure you’re not… but maybe one of the few who admits it.