Reduce size of package manager function

This commit is contained in:
Dylan 2016-04-26 17:31:13 +10:00
parent 0130c3929c
commit 22e888ed48
1 changed files with 10 additions and 20 deletions

View File

@ -687,25 +687,17 @@ getpackages () {
;; ;;
"Mac OS X") "Mac OS X")
if [ -d "/usr/local/bin" ]; then [ -d "/usr/local/bin" ] && \
local_packages=$(ls -l /usr/local/bin/ | grep -v "\(../Cellar/\|brew\)" | wc -l) packages=$(($(ls -l /usr/local/bin/ | grep -v "\(../Cellar/\|brew\)" | wc -l) - 1))
packages=$((local_packages - 1))
fi
if type -p port >/dev/null 2>&1; then type -p port >/dev/null 2>&1 && \
port_packages=$(port installed 2>/dev/null | wc -l) packages=$((packages + $(port installed 2>/dev/null | wc -l) - 1))
packages=$((packages + port_packages - 1))
fi
if type -p brew >/dev/null 2>&1; then type -p brew >/dev/null 2>&1 && \
brew_packages=$(find /usr/local/Cellar -maxdepth 1 2>/dev/null | wc -l) packages=$((packages + $(find /usr/local/Cellar -maxdepth 1 2>/dev/null | wc -l) - 1))
packages=$((packages + brew_packages - 1))
fi
if type -p pkgin >/dev/null 2>&1; then type -p pkgin >/dev/null 2>&1 && \
pkgsrc_packages=$(pkgin list 2>/dev/null | wc -l) packages=$((packages + $(pkgin list 2>/dev/null | wc -l)))
packages=$((packages + pkgsrc_packages))
fi
;; ;;
*"BSD") *"BSD")
@ -721,10 +713,8 @@ getpackages () {
packages=$(cygcheck -cd | wc -l) packages=$(cygcheck -cd | wc -l)
# Count chocolatey packages # Count chocolatey packages
if [ -d "/cygdrive/c/ProgramData/chocolatey/lib" ]; then [ -d "/cygdrive/c/ProgramData/chocolatey/lib" ] && \
choco_packages=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l) packages=$((packages+=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l)))
packages=$((packages + choco_packages))
fi
;; ;;
esac esac
packages=${packages// } packages=${packages// }