just icon indicating copy to clipboard operation
just copied to clipboard

Boolean function `path_exists()` returns string not boolean; not compatible with short-circuit `&&` and `||`

Open cspotcode opened this issue 4 months ago • 2 comments

Not sure if this is intended or not.

I was trying to if path_exists(foo) { a } else { b } or path_exists(foo) && a || b

It wasn't working, I was getting a syntax error. if path_exists(foo) == true also failed. I had to change to path_exists(foo) == 'true'

Is it worth mentioning in the readme that it returns a string, not a boolean? And the caveat with short-circuit logic, since if it returns false, that's not an empty string, won't short-circuit with && or ||.

cspotcode avatar Oct 21 '25 15:10 cspotcode

A lot of this is discussed in https://github.com/casey/just/issues/2411

Is it worth mentioning in the readme that it returns a string, not a boolean?

In justfile everything is a string, there are no other types. I agree that the documentation of path_exists() and semver_matches() do not make clear enough that the true and false return values are the strings "true" and "false".

laniakea64 avatar Oct 21 '25 23:10 laniakea64

https://github.com/casey/just/pull/2946

laniakea64 avatar Nov 10 '25 02:11 laniakea64