Fix Terminal::TryGetBackgroundColor when stdin is reading from a pipe but stdout is still writing to the terminal by Mytherin · Pull Request #21288 · duckdb/duckdb · GitHub
Skip to content

Fix Terminal::TryGetBackgroundColor when stdin is reading from a pipe but stdout is still writing to the terminal - #21288

Merged
Mytherin merged 2 commits into
duckdb:v1.5-variegatafrom
Mytherin:terminalcolorpipe
Mar 11, 2026
Merged

Mytherin merged 2 commits into
duckdb:v1.5-variegatafrom
Mytherin:terminalcolorpipe

Conversation

@Mytherin

Copy link
Copy Markdown
Member

Fixes #21243 and #21245.
Supersedes #21247

Currently when piping stdin to the shell, but not piping stdout, linenoiseGetTerminalColorMode consumes all available input by calling Terminal::BufferAvailableInput() - causing no commands to be executed. This PR adjusts linenoiseGetTerminalColorMode to correctly work when stdin is not a terminal by explicitly opening /dev/tty and running on that instead.

@Mytherin
Mytherin merged commit 12bebb9 into duckdb:v1.5-variegata Mar 11, 2026
48 checks passed
@Mytherin Mytherin mentioned this pull request Mar 12, 2026
2 tasks done
@carlopi carlopi mentioned this pull request Mar 18, 2026
2 tasks done
github-actions Bot pushed a commit to duckdb/duckdb-r that referenced this pull request Mar 18, 2026
Date: 2026-03-12 09:43:16 +0100

Add batch index support to parquet_metadata and friends to allow it to be executed in parallel also with order preservation (duckdb/duckdb#21314)
Fix duckdb/duckdb#21248: correctly expand type count in CSV header detection (duckdb/duckdb#21292)
Fix Terminal::TryGetBackgroundColor when stdin is reading from a pipe but stdout is still writing to the terminal (duckdb/duckdb#21288)
github-actions Bot added a commit to duckdb/duckdb-r that referenced this pull request Mar 18, 2026
Date: 2026-03-12 09:43:16 +0100

Add batch index support to parquet_metadata and friends to allow it to be executed in parallel also with order preservation (duckdb/duckdb#21314)
Fix duckdb/duckdb#21248: correctly expand type count in CSV header detection (duckdb/duckdb#21292)
Fix Terminal::TryGetBackgroundColor when stdin is reading from a pipe but stdout is still writing to the terminal (duckdb/duckdb#21288)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Mar 22, 2026
Date: 2026-03-12 09:43:16 +0100

Add batch index support to parquet_metadata and friends to allow it to be executed in parallel also with order preservation (duckdb/duckdb#21314)
Fix duckdb/duckdb#21248: correctly expand type count in CSV header detection (duckdb/duckdb#21292)
Fix Terminal::TryGetBackgroundColor when stdin is reading from a pipe but stdout is still writing to the terminal (duckdb/duckdb#21288)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr added a commit to krlmlr/duckdb-r-old that referenced this pull request Mar 22, 2026
Date: 2026-03-12 09:43:16 +0100

Add batch index support to parquet_metadata and friends to allow it to be executed in parallel also with order preservation (duckdb/duckdb#21314)
Fix duckdb/duckdb#21248: correctly expand type count in CSV header detection (duckdb/duckdb#21292)
Fix Terminal::TryGetBackgroundColor when stdin is reading from a pipe but stdout is still writing to the terminal (duckdb/duckdb#21288)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr added a commit to krlmlr/duckdb-r-old that referenced this pull request Mar 22, 2026
Date: 2026-03-12 09:43:16 +0100

Add batch index support to parquet_metadata and friends to allow it to be executed in parallel also with order preservation (duckdb/duckdb#21314)
Fix duckdb/duckdb#21248: correctly expand type count in CSV header detection (duckdb/duckdb#21292)
Fix Terminal::TryGetBackgroundColor when stdin is reading from a pipe but stdout is still writing to the terminal (duckdb/duckdb#21288)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
@Mytherin
Mytherin deleted the terminalcolorpipe branch April 28, 2026 07:50
kaka11chen pushed a commit to AstroVela/vane that referenced this pull request Aug 14, 2026
… but stdout is still writing to the terminal (duckdb/duckdb#21288)

Fixes duckdb/duckdb#21243 and
duckdb/duckdb#21245.
Supersedes duckdb/duckdb#21247

Currently when piping `stdin` to the shell, but not piping `stdout`,
`linenoiseGetTerminalColorMode` consumes all available input by calling
`Terminal::BufferAvailableInput()` - causing no commands to be executed.
This PR adjusts `linenoiseGetTerminalColorMode` to correctly work when
`stdin` is not a terminal by explicitly opening `/dev/tty` and running
on that instead.

Upstream-Commit: duckdb/duckdb@12bebb9
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.

1 participant