aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-03-10 22:23:26 +0800
committerAaron LI <aly@aaronly.me>2018-03-10 22:23:26 +0800
commitce76f293885042b6160ab176db9e6d514db5e7c1 (patch)
tree510b44a16d6b7429b7f223848ef6d870a9aaddfe
parent3dc434d3a15d7541107ad92acc777877801de6a9 (diff)
downloaddfly-update-ce76f293885042b6160ab176db9e6d514db5e7c1.tar.bz2
cleanup(): check the item length before test its existence
When there is no $TO_REMOVE_LATE, the generated $tmpfile list has an *empty line* at the end, which cause problem for the file existence test.
-rwxr-xr-xdfly-update3
1 files changed, 2 insertions, 1 deletions
diff --git a/dfly-update b/dfly-update
index d38e1e7..25826a0 100755
--- a/dfly-update
+++ b/dfly-update
@@ -516,8 +516,9 @@ cleanup() {
make -f ${mk_upgrade} -V TO_REMOVE_LATE | tr ' ' '\n' >> ${tmpfile}
# Credit: https://stackoverflow.com/a/10929511
+ # [ -n "${item}" ]: do not ignore the last line if not end with a '\n'
while IFS='' read -r item || [ -n "${item}" ]; do
- if [ -e ${item} -o -L ${item} ]; then
+ if [ -n "${item}" ] && [ -e ${item} -o -L ${item} ]; then
echo " * ${item}"
chflags -Rf noschg ${item}
rm -rf ${item}