Skip to content

openrc-run.sh: spurious break inside case statement in OpenRC 0.63+ #1002

@rapidcow

Description

@rapidcow

In openrc-run.sh there is a break inside a case statement. Previously, this break was enclosed by a for loop. But commit 5a95fe73 from #872 removed that for loop. (This commit is included in release 0.63.)

In POSIX, the behavior of break outside of a loop is unspecified. In practice, break is a no-op1. Shellcheck also documents this. Bash in non-POSIX mode (presumably?) emits a warning, which is how it caught my attention in the first place when I performed a system upgrade on Artix Linux (0.63 to 0.63.1):

(7/9) Reloading system bus configuration...
 * No permission to apply cgroup settings
/usr/lib/openrc/sh/openrc-run.sh: line 313: break: only meaningful in a `for', `while', or `until' loop
 * Reloading D-BUS messagebus config ... [ ok ]

(The permission error was likely triggered because of chroot.)

If the intent is to retain the original logic, then that intent is certainly not honored by the currently stray break, which is acting like a no-op than breaking out of the current case clause.

P.S. The cgroup refactor in #820 also has similar no-op breaks, though that is a draft and not an immediate problem upstream. :)

Footnotes

  1. Tested in all POSIX-compatible shells I could get my hands on: bash 5.3.9(1) with --posix, dash 0.5.13.1, ksh 2020.0.0, busybox 1.36.1 sh. I'm (still) not sure which one OpenRC uses, but I hope that confirms it...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions