Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/uu/ps/src/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ pub(crate) fn collect_pickers(
"time" | "cputime" => pickers.push(helper(time)),
"ucmd" | "comm" => pickers.push(helper(ucmd)),
"cmd" | "command" | "args" => pickers.push(helper(cmd)),
_ => {}
// Not implemented yet: keep the column so later values stay under their headers
_ => pickers.push(helper(|_| "-".to_string())),
}
}

Expand Down
20 changes: 20 additions & 0 deletions tests/by-util/test_ps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,23 @@ fn test_combined_selection_criteria() {
assert!(pids.contains(&1));
assert!(pids.len() > 1);
}

#[test]
#[cfg(target_os = "linux")]
fn test_unimplemented_field_keeps_columns_aligned() {
// wchan has no value yet; pid must still be printed in its own column
let out = new_ucmd!()
.args(&["-p", "1", "--no-headers", "-o", "wchan,pid"])
.succeeds()
.stdout_move_str();
assert_eq!(out.split_whitespace().collect::<Vec<_>>(), ["-", "1"]);

let out = new_ucmd!()
.args(&["-p", "1", "-l"])
.succeeds()
.stdout_move_str();
let mut lines = out.lines();
let headers = lines.next().unwrap().split_whitespace().count();
let values = lines.next().unwrap().split_whitespace().count();
assert_eq!(headers, values);
}
Loading