aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-03-28 18:13:07 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-03-28 18:13:07 +0200
commited034ffb5f04fb58d5f43fa10b6f10e2560928b0 (patch)
tree75e2e1d0ea9dc9e4a0720bf47df9a8f8464d92f7
parent09f698bebd13d7e9036728501a8e728edcf1bfeb (diff)
downloadslackupgrade-ed034ffb5f04fb58d5f43fa10b6f10e2560928b0.tar.gz
slackupgrade-ed034ffb5f04fb58d5f43fa10b6f10e2560928b0.tar.bz2
Fix the -k option.
* slackupgrade: Fix declaration of the -k option Change the value of keep_file to the absolute path name.
-rw-r--r--slackupgrade25
1 files changed, 22 insertions, 3 deletions
diff --git a/slackupgrade b/slackupgrade
index 9be3e98..f00e20b 100644
--- a/slackupgrade
+++ b/slackupgrade
@@ -415,9 +415,23 @@ 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
+}
+
# ##########
# Main
# ##########
-while getopts "ahIknp:qSs:vy" OPTION
+while getopts "ahIk:np:qSs:vy" OPTION
do
case $OPTION in
@@ -427,5 +441,6 @@ do
h) usage
exit 0;;
- k) keep_file=$OPTARG;;
+ k) keep_file=$OPTARG
+ abspath keep_file;;
n) dry_run=y;;
p) install_packages="$install_packages $OPTARG";;
@@ -452,4 +467,8 @@ if [ $(id -u) != "0" ]; then
fi
+if [ -n "$keep_file" ] && [ ! -f "$keep_file" ]; then
+ abend "keep file \"$keep_file\" doesn't exist or is unreadable"
+fi
+
# Sanity check
if [ ! -s /etc/os-release ]; then
@@ -597,5 +616,5 @@ 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 | \
tr -s '\n' | sort -u | comm -2 -3 remove.list.$$ - > remove.list

Return to:

Send suggestions and report system problems to the System administrator.