1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #8094 from cakebaker/uname_fix_order_of_output

uname: output OS last
This commit is contained in:
Sylvestre Ledru 2025-06-08 15:16:21 +02:00 committed by GitHub
commit 938fd7860f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,24 +38,21 @@ pub struct UNameOutput {
impl UNameOutput { impl UNameOutput {
fn display(&self) -> String { fn display(&self) -> String {
let mut output = String::new(); [
for name in [
self.kernel_name.as_ref(), self.kernel_name.as_ref(),
self.nodename.as_ref(), self.nodename.as_ref(),
self.kernel_release.as_ref(), self.kernel_release.as_ref(),
self.kernel_version.as_ref(), self.kernel_version.as_ref(),
self.machine.as_ref(), self.machine.as_ref(),
self.os.as_ref(),
self.processor.as_ref(), self.processor.as_ref(),
self.hardware_platform.as_ref(), self.hardware_platform.as_ref(),
self.os.as_ref(),
] ]
.into_iter() .into_iter()
.flatten() .flatten()
{ .map(|name| name.as_str())
output.push_str(name); .collect::<Vec<_>>()
output.push(' '); .join(" ")
}
output
} }
pub fn new(opts: &Options) -> UResult<Self> { pub fn new(opts: &Options) -> UResult<Self> {
@ -138,7 +135,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
os: matches.get_flag(options::OS), os: matches.get_flag(options::OS),
}; };
let output = UNameOutput::new(&options)?; let output = UNameOutput::new(&options)?;
println!("{}", output.display().trim_end()); println!("{}", output.display());
Ok(()) Ok(())
} }