Fossil User Forum

`fossil which’ command
Login

`fossil which’ command

`fossil which' command

(1) By Florian Balmer (florian.balmer) on 2025-03-16 19:45:22 [link] [source]

Not sure if Fossil really needs a fossil which command. I think this just adds clutter to the online help and makes it harder to find other, more important commands.

On Windows, for maybe two decades already, there's been the where command, which is far superior to fossil which. Not sure about the *nix which command, but at least on Windows, fossil which doesn't add any functionality.

And, we already have test-which to test Fossil functionality.

(2) By Richard Hipp (drh) on 2025-03-16 23:03:24 in reply to 1 [link] [source]

I didn't know about the "where" command on Windows. Learned something today....

Anyhow, the new "fossil which" command does not show up on help output, unless you specify the --all option. In this sense, it is similar to commands like "fossil sha3sum" and "fossil 3-way-diff" - commands that are not central to the mission of Fossil, but which are convenient to have handy and which are easy to implement by leveraging Fossil's infrastructure. Such commands are always available and are cross-platform, but do not show up on "help", unless specifically requested, to avoid clutter.

The "fossil which" command adds value as follows:

  • It uses the same command name on all platforms, so I don't have to think about what platform I'm on before invoking it.

  • It is always available (as long as "fossil" itself is on PATH). No need to "brew install" or "apt install" or whatever.

  • The "fossil which" provides the useful -a option that shows all instances of the executable, anywhere on PATH, a feature "where" does not provide, at least as far as I can see.

  • The "fossil which" command is useful for testing the internal fossil_app_on_path() function that is used by other commands, and which would be difficult to test otherwise.

(3) By Florian Balmer (florian.balmer) on 2025-03-17 06:27:31 in reply to 2 [source]

It is always available (as long as "fossil" itself is on PATH). No need to "brew install" or "apt install" or whatever.

The where.exe utility is in the Windows system directory by default.

The "fossil which" provides the useful -a option that shows all instances of the executable, anywhere on PATH, a feature "where" does not provide, at least as far as I can see.

It's the default behavior of the where utility to list all executable instances on PATH. If you only need the first entry in a script, you have to filter it. But this is rarely necessary, because if you already have a pathname, you can use it verbatim if the where test succeeds, and there are better ways to get full/canonicalized pathnames in scripts.

And where can also search other PATH-like environment variables, for example INCLUDE or LIB, also for non-executable files, if desired.

Plus, where returns a meaningful exit code (super-handy for scripting!), something Fossil doesn't do consistently.