'How to check if a program is present in the system with Raku?
I want to look if cmake is installed in my system with Raku.
cmake --version at my command line gives:
cmake version 3.23.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
One way I know (not sure if it is right or there are better ways) is:
my $cmake = shell('cmake --version').exitcode;
die "Aborting !, cmake installation is not present,
Install and try again," if $cmake != 0;
Is it a right way? Are there other better ways to handle it?
Its quite a generic question, it can help to test any other program.
Solution 1:[1]
Well, I'd probably use something like this, which does not depend on a specific command line argument
die unless shell "which @*ARGS[0]";
It will print the path if it finds it, die if it does not. But if your script works for you, there is more than one way to do it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jjmerelo |
