Suman
Suman

Reputation: 3545

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.

Upvotes: 5

Views: 134

Answers (1)

jjmerelo
jjmerelo

Reputation: 23517

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.

Upvotes: 1

Related Questions