659
edits
Carandraug (talk | contribs) (→Programs, Libraries, and Packages: add recipe to check if package is missing) |
Carandraug (talk | contribs) (→Find if a package is installed: use pkg list instead of pkg describe, because describe has an odd behaviour) |
||
Line 35: | Line 35: | ||
==== Solution ==== | ==== Solution ==== | ||
Use {{codeline|pkg (" | Use {{codeline|pkg ("list", pkg-name)}} like so: | ||
if (! isempty (pkg (" | if (! isempty (pkg ("list", "foo"))) | ||
## use functions from package foo, the prefered way | ## use functions from package foo, the prefered way | ||
elseif (! isempty (pkg (" | elseif (! isempty (pkg ("list", "bar"))) | ||
## use functions from package bar, not so optimal | ## use functions from package bar, not so optimal | ||
else | else | ||
Line 65: | Line 65: | ||
## Again, doesn't add anything. The failure of 'pkg load' is enough | ## Again, doesn't add anything. The failure of 'pkg load' is enough | ||
if (isempty (pkg (" | if (isempty (pkg ("list", "foo"))) | ||
error ("program: package foo is not installed"); | error ("program: package foo is not installed"); | ||
endif | endif |