Python 3 has the very useful shutil.which
(https://docs.python.org/3/library/shutil.html#shutil.which) function. Is there an equivalent for Scala?
For context, I want to run a shell command in scala to get a notification to the user. For example, in the case of ubuntu, something like Seq("notify-send", title, msg) !
(using sys.process
from the standard library). But I want to check beforehand if command
is in the system path, so I can give an informative error message.
I'd like to avoid resorting to parsing (i.e. splitting on :
) and iterating over the folders manually. Another alternative would be Seq("which", "command") !
, but that doesn't work on windows (right?).