fix(tmux): pin pane commands to /bin/sh
This commit is contained in:
committed by
YeonGyu-Kim
parent
8c5ca73634
commit
91f1cf5fbc
@@ -2,6 +2,19 @@ import { describe, expect, it } from "bun:test"
|
|||||||
import { buildTmuxAttachCommand, buildTmuxPlaceholderCommand } from "./pane-command"
|
import { buildTmuxAttachCommand, buildTmuxPlaceholderCommand } from "./pane-command"
|
||||||
|
|
||||||
describe("buildTmuxAttachCommand", () => {
|
describe("buildTmuxAttachCommand", () => {
|
||||||
|
it("uses /bin/sh instead of inheriting SHELL", () => {
|
||||||
|
const originalShell = process.env.SHELL
|
||||||
|
process.env.SHELL = "/bin/tcsh"
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cmd = buildTmuxAttachCommand("http://localhost:3000", "ses_abc123")
|
||||||
|
expect(cmd.startsWith('/bin/sh -c "')).toBe(true)
|
||||||
|
expect(cmd).not.toContain("/bin/tcsh -c")
|
||||||
|
} finally {
|
||||||
|
process.env.SHELL = originalShell
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it("escapes serverUrl shell metacharacters", () => {
|
it("escapes serverUrl shell metacharacters", () => {
|
||||||
const cmd = buildTmuxAttachCommand("http://localhost:3000$(whoami);rm -rf /", "ses_abc123")
|
const cmd = buildTmuxAttachCommand("http://localhost:3000$(whoami);rm -rf /", "ses_abc123")
|
||||||
expect(cmd).toContain("\\$")
|
expect(cmd).toContain("\\$")
|
||||||
@@ -17,6 +30,19 @@ describe("buildTmuxAttachCommand", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("buildTmuxPlaceholderCommand", () => {
|
describe("buildTmuxPlaceholderCommand", () => {
|
||||||
|
it("uses /bin/sh instead of inheriting SHELL", () => {
|
||||||
|
const originalShell = process.env.SHELL
|
||||||
|
process.env.SHELL = "/bin/csh"
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cmd = buildTmuxPlaceholderCommand("My Task")
|
||||||
|
expect(cmd.startsWith('/bin/sh -c "')).toBe(true)
|
||||||
|
expect(cmd).not.toContain("/bin/csh -c")
|
||||||
|
} finally {
|
||||||
|
process.env.SHELL = originalShell
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it("produces inert placeholder command instead of immediate attach", () => {
|
it("produces inert placeholder command instead of immediate attach", () => {
|
||||||
const cmd = buildTmuxPlaceholderCommand("My Task")
|
const cmd = buildTmuxPlaceholderCommand("My Task")
|
||||||
expect(cmd).toContain("Focus this pane to attach.")
|
expect(cmd).toContain("Focus this pane to attach.")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { shellEscapeForDoubleQuotedCommand } from "../../shell-env"
|
|||||||
|
|
||||||
const TMUX_COMMAND_SHELL = "/bin/sh"
|
const TMUX_COMMAND_SHELL = "/bin/sh"
|
||||||
|
|
||||||
export function buildTmuxAttachCommand(serverUrl: string, sessionId: string, directory: string): string {
|
export function buildTmuxAttachCommand(serverUrl: string, sessionId: string, directory: string = process.cwd()): string {
|
||||||
const escapedUrl = shellEscapeForDoubleQuotedCommand(serverUrl)
|
const escapedUrl = shellEscapeForDoubleQuotedCommand(serverUrl)
|
||||||
const escapedSessionId = shellEscapeForDoubleQuotedCommand(sessionId)
|
const escapedSessionId = shellEscapeForDoubleQuotedCommand(sessionId)
|
||||||
const escapedDirectory = shellEscapeForDoubleQuotedCommand(directory || process.cwd())
|
const escapedDirectory = shellEscapeForDoubleQuotedCommand(directory || process.cwd())
|
||||||
|
|||||||
Reference in New Issue
Block a user