diff --git a/net/nut/files/libhid-ups.hotplug b/net/nut/files/libhid-ups.hotplug index e3d3546914..140ac5656c 100644 --- a/net/nut/files/libhid-ups.hotplug +++ b/net/nut/files/libhid-ups.hotplug @@ -228,9 +228,6 @@ perform_libhid_action() { local nd_driver_config_error=false local pvendid pprodid - [ -n "$DEVNAME" ] || return 0 - [ -n "$ACTION" ] || return 0 - # Only find statepath and runas once per event # defines STATEPATH find_statepath "upsd" "nut_server" || { @@ -313,24 +310,28 @@ perform_libhid_action() { # return) and shellcheck will complain if we do. } +# Ignore incomplete (for our purposes) events +[ -n "$DEVNAME" ] || exit 0 +[ -n "$ACTION" ] || exit 0 + # PRODUCT comes from the calling hotplug event, and # is of the form vendorid/productid/other # This is an incomplete script which gets filled by libhid-ups.parsed-usermap. + +# The result is cases of the form +# "vendorid/productid/other" ) | \ +# to be matched against the PRODUCT from the calling hotplug event +# The empty string matches when PRODUCT is empty, but does not match +# when PRODUCT is neither empty nor one of the case targets, above + # This confuses shellcheck and reviewers, hence the disables below. # shellcheck disable=SC1073,SC1072 case "$PRODUCT" in ### insert libhid-ups.parsed-usermap content here ### -# The result is cases of the form -# "vendorid/productid/other" ) | \ -# to be matched against the PRODUCT from the calling hotplug event -# and does NOT use ';;' (so falls through to code below). -# The empty string matches when PRODUCT is empty, but does not match -# when PRODUCT is neither empty nor one of the case targets, above - "") # Skip hotplug actions if NUT hotplug is disabled - # Uses NUT_DISABLE_HOTPLUG_PATH, defined in nut-service.sh and sourced + # Uses NUT_DISABLE_HOTPLUG_PATH, defined in nut-service.sh and sourced # NUT_DISABLE_HOTPLUG_PATH is an external sentinel used to indicate NUT # hotplug is disabled. if ! allow_hotplug_restart; then diff --git a/net/nut/files/nut-serial.hotplug b/net/nut/files/nut-serial.hotplug index c8e0f368d0..7a7988d8c9 100644 --- a/net/nut/files/nut-serial.hotplug +++ b/net/nut/files/nut-serial.hotplug @@ -159,6 +159,10 @@ nut_on_hotplug_add() { return 0 } +# Ignore incomplete (for our purposes) events +[ -n "$DEVNAME" ] || exit 0 +[ -n "$ACTION" ] || exit 0 + # Do not do any hotplug actions if hotplug is disabled. Not an error but log # for information if ! allow_hotplug_restart; then