Skip to content

[Bug] Rubash corrupts quoted awk -F '\t' arguments in pipelines #64

Closed

Description

@caomengxuan666

Summary

When Rubash executes an external awk command in a pipeline, a quoted field separator such as awk -F '\t' ... can be corrupted before the child process receives the argument. The same script executed by Winuxsh sh does not show the corruption.

The reported production symptom is that awk -F '\t' is observed as awk -F T:/. In the current local checkout I reproduced the same class of Rubash-owned argv corruption as an internal control character inserted into the awk program argument. The exact T:/ spelling was not reproduced on this checkout, so it may depend on the embedding/runtime version.

Reproduction

From the repository root:

target/debug/rubash.exe target/awk-fs-repro.sh

target/awk-fs-repro.sh:

#!/bin/sh
printf 'a\tb\n' | awk -F '\t' 'BEGIN { print "FS=[" FS "] len=" length(FS) } { print "field1=[" $1 "]" }'

Compare with:

sh target/awk-fs-repro.sh

Observed

Winuxsh sh:

FS=[\t] len=2
field1=[a]

Rubash:

FS=<control-character>[\t] len=2
field1=<control-character>[a]

The control character is present only in the Rubash pipeline result. A standalone Rubash invocation such as awk -F '\t' 'BEGIN { print FS }' prints the expected \t, so this is likely related to pipeline command-word expansion or external argv preparation.

Expected

Rubash must pass the literal two-character argument \t to awk -F, and must preserve the awk program argument byte-for-byte after shell quote removal.

Initial investigation

Potential owners:

  • src/executor/command_prepare.rs, especially expand_command_word and field_split_escaped_ifs
  • pipeline command preparation in src/executor/pipeline_exec.rs
  • external argv conversion in src/executor/path.rs

command_prepare.rs uses an internal protected-IFS marker while field-splitting escaped IFS characters. The observed control character is consistent with a marker escaping the intended cleanup path. Please add a focused regression that captures the exact argv passed to an external helper and then fix the root cause rather than changing expected output.

Environment

  • Repository: unixwin/rubash
  • Platform: Windows / Winuxsh
  • Rubash checkout: current master checkout

Activity

  1. caomengxuan666 commented on Aug 24, 2026

    @caomengxuan666
    MemberAuthor

    Root cause fixed in the working tree: external pipeline stages now use metadata-aware expand_command_word and restore the same pathname/quote markers as the normal command path. Added regression: external_pipeline_preserves_quoted_awk_field_separator_argument. Focused CLI regression passes; the reproduction now emits FS=[\t] without the 0x11 marker.

  2. caomengxuan666 commented on Sep 21, 2026

    @caomengxuan666
    MemberAuthor

    映射缺口补录(2026-09-22):缺失的修复提交为 7baee60(2026-08-24,fix bash compatibility expansion and bashdb fixtures)——改 command_prepare.rs 等 external pipeline 词元展开路径(metadata-aware expand_command_word),同时引入回归测试 external_pipeline_preserves_quoted_awk_field_separator_argument(tests/cli_tests/compat_issue_regressions.rs:1613,断言 FS=[\t] 无 0x11 标记)。2026-09-22 实测 printf 'a\tb\n' | awk -F '\t' '{print $2}' 双侧输出一致。关闭。

  3. added
    bug
    area:path
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:pathbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions