aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2019-10-01 23:24:26 +0300
committerDylan Araps <dylan.araps@gmail.com>2019-10-01 23:24:26 +0300
commitd8d8899ad2cffabdbc6e405e37bf6478879e1fa4 (patch)
tree35ce44748bef50803e7001c94ebc8e62e3c74cdb
parent1ff17055b958fb2436bb9810bfba0d97c64390a4 (diff)
downloadpfetch-d8d8899ad2cffabdbc6e405e37bf6478879e1fa4.tar.gz
macOS: Fix port false positive
-rwxr-xr-xpfetch16
1 files changed, 15 insertions, 1 deletions
diff --git a/pfetch b/pfetch
index 9cf1796..d1c2ea6 100755
--- a/pfetch
+++ b/pfetch
@@ -455,10 +455,24 @@ get_pkgs() {
Darwin*)
# Commands which print packages one per line.
has pkgin && pkgin list
- has port && port installed
# Directories containing packages.
has brew && printf '%s\n' /usr/local/Cellar/*
+
+ # 'port' prints a single line of output to 'stdout'
+ # when no packages are installed and exits with
+ # success causing a false-positive of 1 package
+ # installed.
+ #
+ # 'port' should really exit with a non-zero code
+ # in this case to allow scripts to cleanly handle
+ # this behavior.
+ has port && {
+ pkg_list=$(port installed)
+
+ [ "$pkg_list" = "No ports are installed." ] ||
+ printf '%s\n' "$pkg_list"
+ }
;;
FreeBSD*|DragonFly*)