FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: avoid bash-only [[ in current_session_name by akofink · Pull Request #1003 · tmuxinator/tmuxinator · GitHub

fix: avoid bash-only [[ in current_session_name - #1003

Merged
akofink merged 2 commits into
tmuxinator:masterfrom
akofink:akofink/fix-978-stop-all-sh-error
Jul 10, 2026
Merged

akofink merged 2 commits into
tmuxinator:masterfrom
akofink:akofink/fix-978-stop-all-sh-error

Conversation

akofink commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Metadata

Fixes #978

Problem / Motivation

tmuxinator stop_all prints sh: 1: [[: not found for each stopped session when /bin/sh is dash (Debian, Ubuntu, Linux Mint).

Util#current_session_name shells out with bash-only [[ ... ]], and Ruby backticks run under /bin/sh.

Solution

  • CHANGELOG entry is added for code changes

Resolve the current session name in Ruby via ENV.key?("TMUX") before calling tmux display-message, so no shell conditional is required.

Testing

Added unit coverage for #current_session_name with and without TMUX set.

Reproduced the original dash error with:

docker run --rm debian:bookworm-slim sh -c '[[ -n "${TMUX+set}" ]] && echo ok'
# => sh: 1: [[: not found

Metadata

Fixes tmuxinator#978

Problem

`stop_all` shells out through `Util#current_session_name`, which uses bash-only
`[[ ... ]]` inside Ruby backticks. On systems where `/bin/sh` is dash (Debian,
Ubuntu, Linux Mint), each stop prints `sh: 1: [[: not found`.

Solution

Check `ENV.key?("TMUX")` in Ruby before running `tmux display-message`, add
unit coverage for both branches, and document the fix in the unreleased
changelog.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Fixes tmuxinator stop_all emitting sh: 1: [[: not found on systems where /bin/sh is dash, by removing a bash-only [[ ... ]] conditional from Util#current_session_name and handling the “not in tmux” case in Ruby.

Changes:

  • Return early from Util#current_session_name when TMUX is not present in the environment (no shell conditional needed).
  • Keep the tmux display-message -p "#S" call only for the in-tmux case.
  • Add unit tests covering #current_session_name with and without TMUX set, plus a CHANGELOG entry.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/tmuxinator/util.rb Replaces bash-only conditional with a Ruby ENV.key?("TMUX") guard before shelling out to tmux.
spec/lib/tmuxinator/util_spec.rb Adds specs for current_session_name behavior when TMUX is present/absent.
CHANGELOG.md Documents the POSIX /bin/sh compatibility fix for stop_all.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/lib/tmuxinator/util_spec.rb Outdated
Comment thread spec/lib/tmuxinator/util_spec.rb Outdated
Metadata

Follow-up to tmuxinator#1003 / tmuxinator#978

Problem

ENV restoration used truthiness of the original value, so an empty-string
TMUX would not be restored correctly across examples.

Solution

Track whether TMUX was originally present with ENV.key? and restore or
delete accordingly via a small with_env helper.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

akofink merged commit 6d021f7 into tmuxinator:master Jul 10, 2026
6 checks passed
akofink deleted the akofink/fix-978-stop-all-sh-error branch July 10, 2026 15:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Running stop_all triggers sh error

2 participants


Back | FazBrowse Home | New Git URL