Skip to content

fix(batch): emit BATCH.sh wrapper with invoking binary path - #5906

Merged
oferchen merged 2 commits into
masterfrom
fix/uts-batch-mode-batchsh-template-2
Jun 18, 2026
Merged

oferchen merged 2 commits into
masterfrom
fix/uts-batch-mode-batchsh-template-2

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Upstream rsync's batch.c:259 writes raw_argv[0] literally into the generated BATCH.sh so the replay script works regardless of PATH. oc-rsync was hardcoding the bare name oc-rsync into the wrapper, which fails with ./BATCH.sh: line 1: oc-rsync: command not found (exit 127) when the binary is invoked by absolute path - notably from the upstream testsuite and from CI.
  • Add an invoker field to BatchConfig (defaulting to "oc-rsync" for backward compatibility) and a with_invoker builder method. The CLI workflow captures std::env::args_os().next() and threads it into the BatchConfig for both --write-batch and --only-write-batch modes.
  • generate_script_with_filters now writes config.invoker through shell_quote so paths with spaces are safely single-quoted.

CI failure reproduced

CI run 27711564454 on master HEAD f5821c3b5 failed the upstream-testsuite batch-mode test at the BATCH.sh use of --read-batch step:

Test BATCH.sh use of --read-batch: Running: "./BATCH.sh"
./BATCH.sh: line 1: oc-rsync: command not found
Failed:  status=127 dir-diff file-diff

The runner invokes the binary by absolute path (/home/runner/work/rsync/rsync/target/release/oc-rsync), so the generated wrapper that referenced bare oc-rsync could not be resolved through PATH.

Upstream reference

target/interop/upstream-src/rsync-3.4.4/batch.c:259:

/* Write argvs info to BATCH.sh file */
err |= write_arg(raw_argv[0]);

Upstream writes the literal invocation path the user passed on the command line. This change mirrors that behavior.

Test plan

  • New unit test test_generate_script_embeds_absolute_invoker_path exercises the failure mode by configuring an absolute invoker and asserting the wrapper starts with that path.
  • New unit test test_generate_script_quotes_invoker_with_spaces covers shell-safe quoting of paths with spaces.
  • New unit test test_generate_script_default_invoker_is_bare_name pins the backward-compatible default for callers that don't configure an invoker.
  • The existing test_generate_script continues to assert the script contains oc-rsync, validating that the default path is preserved.
  • Upstream testsuite batch-mode should now pass the BATCH.sh use of --read-batch phase that was failing with command not found.

@github-actions github-actions Bot added the bug Something isn't working label Jun 17, 2026
@oferchen
oferchen force-pushed the fix/uts-batch-mode-batchsh-template-2 branch from 5b347f6 to 7568dbd Compare June 17, 2026 21:23
Upstream rsync's `batch.c:259` writes `raw_argv[0]` into the generated
`BATCH.sh` so the replay script works regardless of `PATH`. oc-rsync
was hardcoding the bare name `oc-rsync` into the wrapper, which fails
with `./BATCH.sh: line 1: oc-rsync: command not found` (exit 127) when
the binary is invoked by absolute path - notably from the upstream
testsuite and from CI, where the runner executes
`/home/runner/.../target/release/oc-rsync --write-batch=BATCH ...` and
the generated wrapper falls back on a `PATH` lookup that does not find
the bare `oc-rsync` name.

This was the failure observed on the upstream-testsuite `batch-mode`
test on master at HEAD f5821c3 (CI run 27711564454):

    Test BATCH.sh use of --read-batch: Running: "./BATCH.sh"
    ./BATCH.sh: line 1: oc-rsync: command not found
    Failed:  status=127 dir-diff file-diff

Add an `invoker` field to `BatchConfig` (defaulting to `"oc-rsync"`
for backward compatibility) and a `with_invoker` builder method.
`generate_script_with_filters` now writes `config.invoker` through
`shell_quote` so paths with spaces are safely single-quoted. The CLI
workflow captures `std::env::args_os().next()` and threads it into
the `BatchConfig` for both `--write-batch` and `--only-write-batch`
modes, exactly mirroring upstream's `raw_argv[0]` semantics.

Includes three regression tests:
- absolute invoker path is embedded verbatim
- invoker paths with spaces are shell-quoted
- default invoker remains the bare `oc-rsync` name
@oferchen
oferchen force-pushed the fix/uts-batch-mode-batchsh-template-2 branch from 7568dbd to 71357f3 Compare June 18, 2026 03:17
@oferchen
oferchen merged commit 7fe6373 into master Jun 18, 2026
15 of 64 checks passed
@oferchen
oferchen deleted the fix/uts-batch-mode-batchsh-template-2 branch June 18, 2026 04:16
oferchen added a commit that referenced this pull request Aug 24, 2026
Upstream rsync's `batch.c:259` writes `raw_argv[0]` into the generated
`BATCH.sh` so the replay script works regardless of `PATH`. oc-rsync
was hardcoding the bare name `oc-rsync` into the wrapper, which fails
with `./BATCH.sh: line 1: oc-rsync: command not found` (exit 127) when
the binary is invoked by absolute path - notably from the upstream
testsuite and from CI, where the runner executes
`/home/runner/.../target/release/oc-rsync --write-batch=BATCH ...` and
the generated wrapper falls back on a `PATH` lookup that does not find
the bare `oc-rsync` name.

This was the failure observed on the upstream-testsuite `batch-mode`
test on master at HEAD 0171248 (CI run 27711564454):

    Test BATCH.sh use of --read-batch: Running: "./BATCH.sh"
    ./BATCH.sh: line 1: oc-rsync: command not found
    Failed:  status=127 dir-diff file-diff

Add an `invoker` field to `BatchConfig` (defaulting to `"oc-rsync"`
for backward compatibility) and a `with_invoker` builder method.
`generate_script_with_filters` now writes `config.invoker` through
`shell_quote` so paths with spaces are safely single-quoted. The CLI
workflow captures `std::env::args_os().next()` and threads it into
the `BatchConfig` for both `--write-batch` and `--only-write-batch`
modes, exactly mirroring upstream's `raw_argv[0]` semantics.

Includes three regression tests:
- absolute invoker path is embedded verbatim
- invoker paths with spaces are shell-quoted
- default invoker remains the bare `oc-rsync` name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant