Skip to content

Commit

Permalink
Fix: Only allocate tty for docker exec when stdin is a tty (devcont…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Jul 28, 2023
1 parent bd98a20 commit ac349ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Notable changes.

## July 2023

### [0.50.2]
- Fix: Only allocate tty for `docker exec` when stdin is a tty (https://github.com/devcontainers/cli/issues/606)

### [0.50.1]
- Fix: Allocate pty for `docker exec` (https://github.com/devcontainers/cli/issues/556)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@devcontainers/cli",
"description": "Dev Containers CLI",
"version": "0.50.1",
"version": "0.50.2",
"bin": {
"devcontainer": "devcontainer.js"
},
Expand Down
6 changes: 4 additions & 2 deletions src/spec-shutdown/dockerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,12 @@ export async function dockerComposePtyCLI(params: DockerCLIParameters | PartialP
});
}

export function dockerExecFunction(params: DockerCLIParameters | PartialExecParameters | DockerResolverParameters, containerName: string, user: string | undefined, pty = false): ExecFunction {
export function dockerExecFunction(params: DockerCLIParameters | PartialExecParameters | DockerResolverParameters, containerName: string, user: string | undefined, allocatePtyIfPossible = false): ExecFunction {
return async function (execParams: ExecParameters): Promise<Exec> {
const { exec, cmd, args, env } = toExecParameters(params);
const { argsPrefix, args: execArgs } = toDockerExecArgs(containerName, user, execParams, pty);
// Spawning without node-pty: `docker exec` only accepts -t if stdin is a TTY. (https://github.com/devcontainers/cli/issues/606)
const canAllocatePty = allocatePtyIfPossible && process.stdin.isTTY && execParams.stdio?.[0] === 'inherit';
const { argsPrefix, args: execArgs } = toDockerExecArgs(containerName, user, execParams, canAllocatePty);
return exec({
cmd,
args: (args || []).concat(execArgs),
Expand Down

0 comments on commit ac349ef

Please sign in to comment.