Skip to content

[BUG] occ wrapper does not preserve arguments containing spaces #552

Open

Description

@unknown-error-maker

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The occ wrapper uses $* when passing arguments to php occ through bash -c:

sudo -u abc -s /bin/bash -c "php /app/www/public/occ $*"

This causes arguments containing spaces to lose their original argument boundaries when expanded and interpreted by the inner shell.

As a result, commands that pass a single argument containing spaces may behave incorrectly because the argument gets split into multiple arguments.

Expected Behavior

The wrapper should preserve the original argument boundaries, including arguments containing spaces, quotes, and special characters.

Using "$@" instead of $* would preserve the individual arguments. Ideally, the additional bash -c invocation should also be avoided.

For example:

sudo -u abc -- php /app/www/public/occ "$@"

Steps To Reproduce

  1. Run the LinuxServer Nextcloud container.
  2. Execute an OCC command with an argument containing spaces:
occ config:app:set myapp setting --value="hello world"
  1. Observe that the argument is split into multiple arguments when passed to the underlying OCC command.
  2. Compare with the expected behaviour, where hello world should be passed as a single argument.

Environment

- OS: debian trixie
- How docker service was installed: https://get.docker.com

CPU architecture

arm64

Docker creation

not relevant

Container logs

not relevant

Activity

  1. zaniixx commented on Nov 22, 2026

    @zaniixx

    Beyond spaces, this affects any argument containing shell characters. The inner bash -c re-parses everything, so:

    • --value='p@ss$word!' is stored as p@ss! ($word expands to nothing)
    • ;, | and backticks inside values are executed as shell code (as abc)

    Proposed fix: drop the inner shell and pass arguments as mentioned by unknown-error-maker through directly:

    sudo -u abc -- php /app/www/public/occ "$@"

    What changes:

    Call Before After
    occ config:system:set k --value="hello world" stores hello stores hello world
    occ config:system:set k --value='p@ss$word!' stores p@ss! stores p@ss$word!
    occ "maintenance:mode --on" (one string) works no longer works
    occ maintenance:mode --on works works (unchanged)

    In my opinion this is the best approach. It's the standard way for a wrapper to pass arguments, it makes occ behave like any other CLI tool, and it removes a whole class of quoting and expansion bugs instead of patching around them. The one-string form only worked as a side effect of the bug, so I'd suggest a changelog note rather than keeping it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions