diff --git a/functions.sh b/functions.sh index b655aed..f044a11 100755 --- a/functions.sh +++ b/functions.sh @@ -223,13 +223,32 @@ fi ### end of mac-specific functions -function pipupdate(){ - for pip in pip2 pip3; do - if [ -z $pip ]; then - continue +pipupdate(){ + set -x + if [[ "$1" == "user" ]]; then + user_flags='--user' + shift + fi + if [[ -n "$@" ]]; then + pip="$1" + shift + flags="$*" + echo "pip command is: '$pip $flags'" + if ! command -v "$pip" ; then + echo "Given command ($1) does not exist." 1>&2 + return fi - $pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 $pip install -U + + else + pip='python' + flags='-m pip' + echo "Using default pip: $pip $flags" + fi + + for package in $($pip $flags freeze $user_flags --local | grep -v '^\-e' | cut -d = -f 1) ; do + $pip $flags install "$user_flags" -U "$package" done + set +x } # unzip file to directory with the same name of the zip file (without extension)