Skip to content

Potential compatibility issue: Removing explicit -s /bin/sh from su command may break for users with non-POSIX login shells #129

Description

@kilo-code-bot

Issue Description

In PR #128, the su command used to drop privileges for running Homebrew commands was simplified by removing the explicit shell specification (-s /bin/sh). This change may break compatibility for users with non-POSIX login shells (e.g., fish, nushell, csh, tcsh).

Technical Details

The _brew_cmds variable contains POSIX shell syntax including:

  • eval
  • $() command substitution
  • && logical AND
  • printf with format strings

When su - ${NON_ROOT_USER} -c ${_brew_cmds} is used without -s /bin/sh, it invokes the user's login shell. If that shell is non-POSIX (like fish or nushell), the POSIX syntax in _brew_cmds will fail.

Original Code (with explicit shell)

su - ${NON_ROOT_USER} -s /bin/sh -c ${_brew_cmds}

Current Code (without explicit shell)

su - ${NON_ROOT_USER} -c ${_brew_cmds}

Recommended Fix

Restore -s /bin/sh to guarantee POSIX compliance, or use sh -c explicitly.

Context

This was flagged in the code review for PR #128 by the Kilo Code bot. The review comment can be found at: #128 (comment)

Labels: bug, compatibility, shell


PR Signature to include in the PR description:
If you create a pull request or merge request, include the following signature at the end of the PR/MR description:

Built for gvatsal60 by Kilo

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions