Skip to content

feat(uname): add uname - #286

Merged
ferdingler merged 4 commits into
strands-agents:mainfrom
ferdingler:feat/uname
Nov 19, 2026
Merged

ferdingler merged 4 commits into
strands-agents:mainfrom
ferdingler:feat/uname

Conversation

@ferdingler

@ferdingler ferdingler commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

There's no uname, so the common case "$(uname -s)" in Linux) ... check in install and build scripts fails with command not found.

This adds uname with -s, -n, -r, -v, -m, -p, -i, -o, -a and their long forms. It describes the virtual system, never the host: the kernel name and OS are Linux, the node name follows the same rule as hostname ($HOSTNAME, else localhost), the release is the Strands Shell version, and the kernel version is #1. The machine is the architecture the shell was built for, which is fixed at build time rather than read from the host. Fields always print in GNU's order no matter how the flags are given, and no flags means -s. -p and -i print unknown, and like GNU, -a leaves them out. I also added it to the WASM command list and bumped the command count in the README.

Related Issues

Part of #207

Documentation PR

Type of Change

New feature

Testing

I compared the field order, the default, and the error cases with GNU uname. The new tests cover each flag, -a, flag order, the host name variable, help, and the error cases. The full Rust suite passes and clippy has the same warnings as main. I didn't run the Python or Node suites because the bindings are unchanged. This is one of four small PRs adding whoami, hostname, uname, and id; each stands on its own, but they touch the same command lists, so whichever lands later will need a trivial rebase. Once hostname (#277) and this one are both in, the shared default host name could move to one place.

  • I ran the relevant test suites for the bindings I touched (cargo test --workspace --all-targets, pytest tests/python, npm test)
  • If I touched Rust, I ran cargo fmt and cargo clippy

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ferdingler
ferdingler requested a review from a team as a code owner November 13, 2026 05:17
@ferdingler

Copy link
Copy Markdown
Collaborator Author

@strandly-the-agent Please review this PR

@strandly-the-agent strandly-the-agent mentioned this pull request Nov 13, 2026
9 of 10 tasks
@ferdingler ferdingler mentioned this pull request Nov 13, 2026
10 tasks done

@strandly-the-agent strandly-the-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve. I found nothing blocking. It's correct for the flags it claims, it reads nothing from the host, and every command list that needed uname has it. I'd make one change: accept -p/-i (inline).

@ferdingler, the one 🟡: GNU accepts uname -p and uname -i, prints unknown and exits 0. Here they fail with invalid option and exit 1, so ARCH=$(uname -p) stops a set -e script. It's a 6-line fix that I built and checked against GNU.

What I verified, questions, and nits

Verified at 30134d28

  • cargo test --workspace --all-targets: 2583 passed, 0 failed (13 of them are uname tests).
  • I compared strands-shell -c with GNU coreutils 9.1 on this host:
    • no flags gives Linux, and -asn prints no duplicates and keeps GNU order
    • extra operands and bad options exit 1
    • HOSTNAME= uname -n gives localhost
    • the only mismatch is -p/-i
  • No host leak. The only std::env::var in src/ is vfs_config.rs:204, so $HOSTNAME never comes from the host.
  • The $HOSTNAME/localhost rule matches hostname in #277.
  • The command lists are all updated: the README count (34, which matches list-commands), the WASM lookup in mod.rs, and the /bin links in vfs.rs. type and command -v pick uname up through the inventory. The bindings and MCP description have no command lists.
  • I built the suggested -p/-i fix and checked it: uname -mpio gives aarch64 unknown unknown Linux (GNU gives aarch64 unknown unknown GNU/Linux), -a is unchanged, and the uname tests pass.

Question (non-blocking)

  • uname -r is the crate version: 0.0.0 on dev builds, the stamped version on releases. A script that checks for a minimum kernel version will see a very old kernel. Is that OK?

Nits

  • uname.rs:17: -o prints Linux, and GNU prints GNU/Linux. Common scripts only test -o for Android, Msys or Cygwin, so they aren't affected.
  • HOSTNAME= uname -n falling back to localhost works but has no test. #277 has one.

Comment thread src/commands/uname.rs Resolved
@ferdingler

Copy link
Copy Markdown
Collaborator Author

Thanks. Pushed b860b85 with -p/-i (see the inline reply), a test for the empty HOSTNAME fallback, and error tests that check the actual messages.

On -r being the crate version: that is intentional. Any Linux-looking release string would be made up, and the host kernel version is exactly what we do not want to show. The shell version is the honest answer for what this "kernel" is. A script that gates on a minimum kernel version will see an old one, but those checks are usually about syscalls or kernel features the sandbox does not provide anyway.

On -o printing Linux rather than GNU/Linux: also intentional, since there is no GNU userland here. As you said, common scripts only check -o for Android, Msys, or Cygwin, so either value behaves the same for them.

@ferdingler

Copy link
Copy Markdown
Collaborator Author

@strandly-the-agent Please review this PR

@strandly-the-agent strandly-the-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve (re-review at e7745d0). The -p/-i finding from my last review is fixed and the merge with main is clean. The fix brought in one small GNU mismatch, which doesn't block.

  • Previous 🟡, -p/-i rejected: fixed in b860b85. Both print unknown, exit 0, and sit in GNU's order.
  • New 🟡, minor (inline): uname -snrvmpio prints 6 fields where GNU prints 8. GNU drops the unknown fields only when -a is given, not when the single flags add up to everything.
  • Your answers on -r and -o settle those two; nothing further from me.
What I verified
  • cargo test --workspace --all-targets at e7745d0: 2678 passed, 0 failed, 0 ignored. 16 of them are uname tests.
  • I compared strands-shell -c with GNU coreutils 9.1 (aarch64 Linux):
    • -p, -i, -pi, -mpio, -a, -a -p, -pa and -snrvmo all match GNU's field selection and order
    • uname -z and uname x exit 1 with the messages the new tests assert
    • HOSTNAME= uname -n gives localhost, now covered by uname_n_empty_hostname
    • the only mismatch is -snrvmpio
  • Merge with main: list-commands prints 36, which matches the README. The WASM lookup in mod.rs and the /bin list in vfs.rs have uname alongside the new base64 and id.
  • I built the inline suggestion: -snrvmpio then prints 8 fields, -a, -a -p and -pa stay at 6, and the 16 uname tests pass with the updated expectation.
  • Not run: the Python and Node suites (bindings unchanged) and a WASM build.
  • CI at e7745d0: Rust is green on all three OSes. Three macOS jobs (Python 3.13, Python 3.14, Node 20) were still queued when I posted.

Comment thread src/commands/uname.rs Resolved
GNU drops the unknown processor and platform only for -a, not when the
single flags add up to every field.
@ferdingler

Copy link
Copy Markdown
Collaborator Author

@strandly-the-agent Please review this PR

@strandly-the-agent strandly-the-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve (re-review at cdfa1c9). Both findings from my earlier reviews are fixed, and I have no new ones.

  • uname -snrvmpio dropped the unknown fields: fixed in cdfa1c9. It now prints 8 fields, and -a, -a -p and -pa still print 6, as GNU coreutils 9.1 does.
  • -p/-i rejected: fixed earlier in b860b85, and unchanged by this commit.

The check rollup shows red only because a duplicate 2 Approvers for Bots run was cancelled; its rerun passed and no job has failed. Six macOS jobs were still running when I posted.

What I verified
  • The delta since e7745d0 is 13 lines in uname.rs and one test expectation, and it matches the suggestion.
  • cargo test --workspace --all-targets at cdfa1c9: 2678 passed, 0 failed, 0 ignored. 16 of them are uname tests.
  • cargo fmt --check is clean, and cargo clippy --all-targets reports nothing in uname.rs.
  • strands-shell -c probes, with GNU coreutils 9.1 on the same aarch64 Linux host as the control:
    • -snrvmpio gives Linux localhost 0.0.0 #1 aarch64 unknown unknown Linux
    • -a, -a -p, -pa, -a -s and --all --processor all give the 6-field line
    • no flags still gives Linux; -pi, -mpio, -oips and -snrvmo are unchanged
    • uname -z and uname -a x still exit 1
  • Not run: the Python and Node suites (bindings unchanged) and a WASM build.

@ferdingler
ferdingler merged commit 9455e9f into strands-agents:main Nov 19, 2026
35 of 36 checks passed
@ferdingler
ferdingler deleted the feat/uname branch November 19, 2026 05:40
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