Skip to content

watch: accept a command with arguments and on/off options without values - #869

Open
Harp404 wants to merge 1 commit into
uutils:mainfrom
Harp404:watch-command-args
Open

Harp404 wants to merge 1 commit into
uutils:mainfrom
Harp404:watch-command-args

Conversation

@Harp404

@Harp404 Harp404 commented Dec 1, 2026

Copy link
Copy Markdown

watch only took the command as one word, and its on/off options asked for a value:

$ watch -n1 echo hi
error: unexpected argument 'hi' found
$ watch -t -n1 date
error: a value is required for '--no-title <no-title>' but none was supplied

procps-ng watch accepts both. This change:

  • takes the command as all remaining arguments and joins them with spaces for sh -c, as procps-ng does, so watch ls -l works. Options after the command belong to the command. An unknown option before it is still an error.
  • makes -b -c -C -e -g -p -r -t -w -x plain flags. -d takes no value, and --differences takes an optional =permanent.
  • implements -x/--exec: the arguments are run directly instead of through sh -c, so watch -x printf '%s-' 'a b' prints a b-.

The other flags are parsed but not acted on yet.

The 4 new tests in tests/by-util/test_watch.rs fail on main and pass with this change. cargo fmt and cargo clippy --all-targets -- -D warnings are clean.

I used Claude Code (Opus 5.5) to help investigate and draft this change; I reproduced the bug and checked the fix myself.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 09:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.85714% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.54%. Comparing base (67832aa) to head (053a9ac).
⚠️ Report is 63 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/watch/src/watch.rs 0.00% 33 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #869      +/-   ##
==========================================
+ Coverage   19.20%   20.54%   +1.34%     
==========================================
  Files          68       68              
  Lines       10156    10163       +7     
  Branches      546      552       +6     
==========================================
+ Hits         1950     2088     +138     
+ Misses       8206     8075     -131     
Flag Coverage Δ
macos_latest ?
ubuntu_latest 20.95% <54.41%> (+1.39%) ⬆️
windows_latest 0.02% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants