*/
#include "libbb.h"
+#include <fnmatch.h>
#include "unarchive.h"
/* note: if you vary hash_prime sizes be aware,
* the status_hashtable to retrieve the info. This results in smaller code than
* scanning the status file. The resulting list, however, is unsorted.
*/
-static void list_packages(void)
+static void list_packages(const char *pattern)
{
int i;
name_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->name];
vers_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->version];
+ if (pattern && fnmatch(pattern, name_str, 0))
+ continue;
+
/* get abbreviation for status field 1 */
s1 = stat_str[0] == 'i' ? 'i' : 'r';
/* if the list action was given print the installed packages and exit */
if (opt & OPT_list_installed) {
- list_packages();
+ list_packages(argv[0]);
return EXIT_SUCCESS;
}