On 26/03/2014 19:00, Vsevolod Stakhov wrote:
>> +
>> +		if ((p = getenv("PATH")) == NULL)
>> +			return (EX_USAGE);
>> +		path = malloc(strlen(p)+1);
>> +		if (path == NULL)
>> +			return (EX_OSERR);
>> +
>> +		memcpy(path, p, strlen(p)+1);
>> +
>> +		if (strlen(argv[0]) >= FILENAME_MAX)
>> +			return (EX_USAGE);
>> +
>> +		p = NULL;
>> +		res = get_match(&p, path, argv[0]);
>> +		if (res == (EX_USAGE)) {
>> +			printf("%s was not found in PATH\n", argv[0]);
> 
> This should not be an error, we should just try to find the corresponding file in DB.

How about extending 'pkg which' to search the pkg db and match just the
filename  part (-x) or do regexp (-e) or glob (-g) against the file
name, and equivalently substring (-X), regexp (-E) or glob (-G) matches
against the entire file path?   This changes the meaning of '-g' but I
think it make sense.  Flags follow the same pattern as used when
matching against package names in eg. 'pkg delete'.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.

PGP: http://www.infracaninophile.co.uk/pgpkey
JID: matthew@infracaninophile.co.uk