Repository navigation
feat(uname): add uname - #286
Conversation
|
@strandly-the-agent Please review this PR |
strandly-the-agent
left a comment
There was a problem hiding this comment.
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 areunametests).- I compared
strands-shell -cwith GNU coreutils 9.1 on this host:- no flags gives
Linux, and-asnprints no duplicates and keeps GNU order - extra operands and bad options exit 1
HOSTNAME= uname -ngiveslocalhost- the only mismatch is
-p/-i
- no flags gives
- No host leak. The only
std::env::varinsrc/isvfs_config.rs:204, so$HOSTNAMEnever comes from the host. - The
$HOSTNAME/localhostrule matcheshostnamein #277. - The command lists are all updated: the README count (34, which matches
list-commands), the WASMlookupinmod.rs, and the/binlinks invfs.rs.typeandcommand -vpickunameup through the inventory. The bindings and MCP description have no command lists. - I built the suggested
-p/-ifix and checked it:uname -mpiogivesaarch64 unknown unknown Linux(GNU givesaarch64 unknown unknown GNU/Linux),-ais unchanged, and the uname tests pass.
Question (non-blocking)
uname -ris the crate version:0.0.0on 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:-oprintsLinux, and GNU printsGNU/Linux. Common scripts only test-ofor Android, Msys or Cygwin, so they aren't affected.HOSTNAME= uname -nfalling back tolocalhostworks but has no test. #277 has one.
|
Thanks. Pushed b860b85 with On On |
# Conflicts: # README.md # src/vfs.rs
|
@strandly-the-agent Please review this PR |
strandly-the-agent
left a comment
There was a problem hiding this comment.
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/-irejected: fixed in b860b85. Both printunknown, exit 0, and sit in GNU's order. - New 🟡, minor (inline):
uname -snrvmpioprints 6 fields where GNU prints 8. GNU drops the unknown fields only when-ais given, not when the single flags add up to everything. - Your answers on
-rand-osettle those two; nothing further from me.
What I verified
cargo test --workspace --all-targetsate7745d0: 2678 passed, 0 failed, 0 ignored. 16 of them areunametests.- I compared
strands-shell -cwith GNU coreutils 9.1 (aarch64 Linux):-p,-i,-pi,-mpio,-a,-a -p,-paand-snrvmoall match GNU's field selection and orderuname -zanduname xexit 1 with the messages the new tests assertHOSTNAME= uname -ngiveslocalhost, now covered byuname_n_empty_hostname- the only mismatch is
-snrvmpio
- Merge with
main:list-commandsprints 36, which matches the README. The WASMlookupinmod.rsand the/binlist invfs.rshaveunamealongside the newbase64andid. - I built the inline suggestion:
-snrvmpiothen prints 8 fields,-a,-a -pand-pastay at 6, and the 16unametests 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.
GNU drops the unknown processor and platform only for -a, not when the single flags add up to every field.
|
@strandly-the-agent Please review this PR |
strandly-the-agent
left a comment
There was a problem hiding this comment.
Approve (re-review at cdfa1c9). Both findings from my earlier reviews are fixed, and I have no new ones.
uname -snrvmpiodropped theunknownfields: fixed in cdfa1c9. It now prints 8 fields, and-a,-a -pand-pastill print 6, as GNU coreutils 9.1 does.-p/-irejected: 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
e7745d0is 13 lines inuname.rsand one test expectation, and it matches the suggestion. cargo test --workspace --all-targetsatcdfa1c9: 2678 passed, 0 failed, 0 ignored. 16 of them areunametests.cargo fmt --checkis clean, andcargo clippy --all-targetsreports nothing inuname.rs.strands-shell -cprobes, with GNU coreutils 9.1 on the same aarch64 Linux host as the control:-snrvmpiogivesLinux localhost 0.0.0 #1 aarch64 unknown unknown Linux-a,-a -p,-pa,-a -sand--all --processorall give the 6-field line- no flags still gives
Linux;-pi,-mpio,-oipsand-snrvmoare unchanged uname -zanduname -a xstill exit 1
- Not run: the Python and Node suites (bindings unchanged) and a WASM build.
Description
There's no
uname, so the commoncase "$(uname -s)" in Linux) ...check in install and build scripts fails with command not found.This adds
unamewith-s,-n,-r,-v,-m,-p,-i,-o,-aand their long forms. It describes the virtual system, never the host: the kernel name and OS areLinux, the node name follows the same rule ashostname($HOSTNAME, elselocalhost), 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.-pand-iprintunknown, and like GNU,-aleaves 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 addingwhoami,hostname,uname, andid; each stands on its own, but they touch the same command lists, so whichever lands later will need a trivial rebase. Oncehostname(#277) and this one are both in, the shared default host name could move to one place.cargo test --workspace --all-targets,pytest tests/python,npm test)cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.