Skip to content

Commit f54f118

Browse files
committed
fix(quoting): prevent control chars from triggering quotes in NonEscapedShellQuoter
The initial_quoting_with_show_control function was incorrectly treating control characters as requiring quoting when show_control=true. This caused test_control_chars to fail in the MinRustV CI check. For NonEscapedShellQuoter (used in ls --quoting-style=shell): - Control chars should NOT trigger quoting - When show_control=false: they become '?' (not special) - When show_control=true: shown as-is but still don't need quotes - Only characters in shell_escaped_char_set trigger quoting This differs from EscapedShellQuoter which uses dollar-quoting for control characters. Fixes the test expectation where shell-show mode should NOT wrap control characters in quotes unless always_quote is set.
1 parent 65373e4 commit f54f118

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/uucore/src/lib/features/quoting_style/shell_quoter.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,17 @@ fn initial_quoting_with_show_control(
398398
input: &[u8],
399399
dirname: bool,
400400
always_quote: bool,
401-
show_control: bool,
401+
_show_control: bool,
402402
) -> (Quotes, bool) {
403-
// Check for control characters FIRST - they require $'...' which only works with single quotes
404-
// But only consider them if we're showing them; if hiding, they become '?' which isn't special
405-
let has_control_chars = show_control && input.iter().any(|&c| c < 32 || c == 127);
406-
407-
if has_control_chars
408-
|| input
409-
.iter()
410-
.any(|c| shell_escaped_char_set(dirname).contains(c))
403+
// For NonEscapedShellQuoter, control chars don't trigger quoting.
404+
// When show_control=false, they become '?' which isn't special.
405+
// When show_control=true, they're shown as-is but still don't trigger quoting
406+
// (unlike EscapedShellQuoter which uses dollar-quoting for them).
407+
// Only characters in shell_escaped_char_set trigger quoting.
408+
409+
if input
410+
.iter()
411+
.any(|c| shell_escaped_char_set(dirname).contains(c))
411412
{
412413
(Quotes::Single, true)
413414
} else if input.contains(&b'\'') {

0 commit comments

Comments
 (0)