which function
Searches the PATH for the location of the application
give by appname
.
The search is conducted by searching each of the paths in the environment variable 'PATH' from left to right (start to end) as this is the same order the OS searches the path.
If the verbose
flag is true then a line is output to
the progress
for each path searched.
It is possible that more than one copy of the appliation is found.
which returns a list of paths that contain appname in the order they were found.
The first path in the list is the one the OS will be using.
if the first
flag is true then which will
stop searching as soon as it finds a match.
first
is true by default.
which('ls', first: false, verbose: true);
To print the path to the command:
print(which('ls').path);
To check if an app is on the path use:
if (which('apt').found)
{
print('found apt');
}
Implementation
Which which(String appname,
{bool first = true, bool verbose = false, Progress? progress}) =>
_Which().which(appname, first: first, verbose: verbose, progress: progress);