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
2 changes: 1 addition & 1 deletion src/uu/ps/src/process_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub struct ProcessSelectionSettings {
impl ProcessSelectionSettings {
pub fn from_matches(matches: &ArgMatches) -> Self {
Self {
select_all: matches.get_flag("A"),
select_all: matches.get_flag("A") || matches.get_flag("e"),
select_non_session_leaders_with_tty: matches.get_flag("a"),
select_non_session_leaders: matches.get_flag("d"),
dont_require_tty: matches.get_flag("x"),
Expand Down
5 changes: 4 additions & 1 deletion src/uu/ps/src/ps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ pub fn uu_app() -> Command {
Arg::new("A")
.short('A')
.help("all processes")
.visible_short_alias('e')
.action(ArgAction::SetTrue),
Arg::new("e")
.short('e')
.help("show the environment after command ")
.action(ArgAction::SetTrue),
Arg::new("a")
.short('a')
Expand Down
21 changes: 18 additions & 3 deletions tests/by-util/test_ps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,24 @@ use uucore::process::geteuid;
#[test]
#[cfg(target_os = "linux")]
fn test_select_all_processes() {
for arg in ["-A", "-e"] {
// TODO ensure the output format is correct
new_ucmd!().arg(arg).succeeds();
let expected_headers = ["PID", "TTY", "TIME", "CMD"];

let args_sets = vec![vec!["-A"], vec!["-e"], vec!["-A", "-e"]];
for args in args_sets {
let result = new_ucmd!().args(&args).succeeds();
let lines: Vec<&str> = result.stdout_str().lines().collect();

assert!(
lines.len() >= 2,
"expected at least a header and one process row"
);

let headers: Vec<&str> = lines[0].split_whitespace().collect();
assert_eq!(
headers, expected_headers,
"unexpected header for args: {:?}",
args
);
}
}

Expand Down
Loading