Depending on where the error occurs, mnt_point can be empty. If
this is the case, this error can happen:
Status: 4 message: ERROR util.c : read_lines_notify : 1166 : swupdate-ab.sh: Error: destination partition "/dev/mmcblk0p2" not found
Status: 4 message: ERROR util.c : read_lines_notify : 1166 : swupdate-ab.sh: Error 1 occurred
Status: 4 message: ERROR util.c : read_lines_notify : 1166 : BusyBox v1.36.1 () multi-call binary.
Status: 4 message: ERROR util.c : read_lines_notify : 1166 : Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...
Status: 2 message: [__run_cmd] : /tmp/scripts/swupdate-ab.sh preinst p2 command returned 1
Add check for valid mnt_point before trying to unmount.
{
if [ "$1" != "0" ]; then
# Error handling goes here
- echo "Error $1 occurred"
+ printf >&2 "$(basename ${0}): Error $1 occurred\n"
- if mount | grep -q ${mnt_point}; then
- unmount_destination_partition
+ if [ -n "${mnt_point}" ]; then
+ if mount | grep -q ${mnt_point}; then
+ unmount_destination_partition
+ fi
fi
fi
}