Skip to content

Fix launching remote Bash with shell integration enabled#474

Merged
emil-e merged 1 commit into
mainfrom
fix-remote-bash-arg-order
Jun 26, 2026
Merged

Fix launching remote Bash with shell integration enabled#474
emil-e merged 1 commit into
mainfrom
fix-remote-bash-arg-order

Conversation

@dakra

@dakra dakra commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Problem

Starting a remote Bash shell over TRAMP with ghostel-tramp-shell-integration enabled fails at launch:

/bin/bash: --: invalid option
Usage:  /bin/bash [GNU long option] [option] ...

ghostel assembled the argv as /bin/bash -i --rcfile FILE. Bash requires all multi-character (long) options to come before any single-character options, so the long --rcfile following the short -i is rejected.

This is the same bug as #470; this PR fixes it at the source rather than with a post-hoc argument sort.

Fix

shell-args is built by appending two groups: the login/interactive defaults (-i/-l) and the integration args (bash's --rcfile/--posix, fish's -C). The fix simply swaps the append order so the integration args lead:

(shell-args (append
             integration-args
             (or extra-shell-args
                 (and remote-p
                      (ghostel--default-remote-shell-args
                       shell remote-integration)))))

For remote Bash this yields /bin/bash --rcfile FILE -i, which launches cleanly. The reorder is:

  • zsh — a no-op (integration args are always nil),
  • fish — harmless (no long-before-short rule; -C stays adjacent to its value),
  • local bash — harmless (--posix/--login are order-independent).

User-supplied bash args are not reordered within their own list, so the long-before-short requirement is now documented in the ghostel-shell and ghostel-tramp-shells docstrings.

Verification

  • make -j8 all passes (build + tests + lint).
  • Verified live over TRAMP/SSH against a real remote Bash 4.4.20 host: reproduced the --: invalid option failure without the change, and confirmed a clean interactive prompt with it.

Remote bash with shell integration built the argv as
`/bin/bash -i --rcfile FILE`.  Bash rejects long options that follow
single-character ones, so it failed at launch with
"/bin/bash: --: invalid option".

Swap the append order so the integration args (bash's --rcfile/--posix,
fish's -C) lead the -i/-l defaults.  The order is immaterial for zsh
(no integration args) and fish, and harmless for local bash
(--posix/--login are order-independent).

Document the long-before-short requirement for user-supplied bash args
in `ghostel-shell' and `ghostel-tramp-shells'.
@dakra
dakra force-pushed the fix-remote-bash-arg-order branch from e8604b7 to daccaa2 Compare June 26, 2026 12:25
@emil-e
emil-e merged commit 86b670a into main Jun 26, 2026
43 of 44 checks passed
@emil-e
emil-e deleted the fix-remote-bash-arg-order branch June 26, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants