diff options
-rw-r--r-- | slackupgrade | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/slackupgrade b/slackupgrade index 9be3e98..f00e20b 100644 --- a/slackupgrade +++ b/slackupgrade @@ -416,2 +416,16 @@ function download_all() { +function abspath() { + local name=$1 + local val + eval val=\$$name + case $val in + /*) ;; + *) local dir=$(dirname $val) + dir=$(cd $dir 2>/dev/null && pwd) || abend "can't canonicalize $val" + val=$dir/$(basename $val) + eval $name=$val + ;; + esac +} + # ########## @@ -420,3 +434,3 @@ function download_all() { -while getopts "ahIknp:qSs:vy" OPTION +while getopts "ahIk:np:qSs:vy" OPTION do @@ -428,3 +442,4 @@ do exit 0;; - k) keep_file=$OPTARG;; + k) keep_file=$OPTARG + abspath keep_file;; n) dry_run=y;; @@ -453,2 +468,6 @@ fi +if [ -n "$keep_file" ] && [ ! -f "$keep_file" ]; then + abend "keep file \"$keep_file\" doesn't exist or is unreadable" +fi + # Sanity check @@ -598,3 +617,3 @@ fi) | sort -u > candidates.$$ comm -2 -3 $installed_list candidates.$$ > remove.list.$$ -if [ -s "$keep_file" ]; then +if [ -n "$keep_file" ] && [ -s "$keep_file" ]; then grep -v '^#' $keep_file | \ |