base-files: sysupgrade: exit with no error for --help
[openwrt/staging/stintel.git] / package / base-files / files / sbin / sysupgrade
index 08f92c659f4a15d198edc82109d4165dfc7bbcf2..592b1f378165a078d1a0ac13d4fd39780ac3aaca 100755 (executable)
@@ -63,9 +63,7 @@ while [ -n "$1" ]; do
        shift;
 done
 
-IMAGE="$1"
-
-[ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 -o $HELP -gt 0 ] && {
+print_help() {
        cat <<EOF
 Usage: $0 [<upgrade-option>...] <image file or URL>
        $0 [-q] [-i] [-c] [-u] [-o] [-k] <backup-command> <file>
@@ -105,9 +103,20 @@ backup-command:
                     sysupgrade -b. Does not create a backup file.
 
 EOF
-       exit 1
 }
 
+IMAGE="$1"
+
+if [ $HELP -gt 0 ]; then
+       print_help
+       exit 0
+fi
+
+if [ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 ]; then
+       print_help
+       exit 1
+fi
+
 [ -n "$IMAGE" -a -n "$NEED_IMAGE" ] && {
        cat <<-EOF
                -b|--create-backup and -r|--restore-backup do not perform a firmware upgrade.