commit 81cd88bdadfa7a2485800288c6a9a4f606194d6e parent 8aee505726c9fcdf5cd1dca70072e65e62825dfe Author: gearsix <gearsix@tuta.io> Date: Mon, 4 Apr 2022 10:09:45 +0100 minor fix to file checks Diffstat:
M | xpm.sh | | | 18 | ++++++++++++------ |
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/xpm.sh b/xpm.sh @@ -22,7 +22,7 @@ usage() { exec_hooks() { if [ $1 = "" ]; then return; fi - if [ ! -e $HOOKS_DIR ]; then mkdir -p $HOOKS_DIR; fi + if [ ! -d $HOOKS_DIR ]; then mkdir -p $HOOKS_DIR; fi for f in $HOOKS_DIR/*; do if [ "$(basename $f)" = "$1" ]; then @@ -39,6 +39,10 @@ installed_add() { mkdir -p $(dirname $INSTALLED) fi + if [ ! -e $INSTALLED ]; then + touch $INSTALLED + fi + for pkg in $@; do if [ "$(grep $pkg $INSTALLED)" = "" ]; then echo $pkg >> "$INSTALLED" @@ -49,11 +53,13 @@ installed_add() { installed_rm() { if [ $XPM_NOTRACK ]; then return; fi - for pkg in $@; do - if [ "$(grep $pkg $INSTALLED)" != "" ]; then - sed -i "/$pkg/d" "$INSTALLED" - fi - done + if [ -e $INSTALLED ]; then + for pkg in $@; do + if [ "$(grep $pkg $INSTALLED)" != "" ]; then + sed -i "/$pkg/d" "$INSTALLED" + fi + done + fi } unknown_pm() {