Fix ps command to show process name only (#4544)

* Fix `ps` command to show process name only

* Remove `command_only` -  it is no longer being used
This commit is contained in:
Joseph T. Lyons 2022-02-18 20:48:52 -05:00 committed by GitHub
parent da42100374
commit 3ecf17e7af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -303,13 +303,21 @@ impl ProcessInfo {
/// Name of command /// Name of command
pub fn name(&self) -> String { pub fn name(&self) -> String {
// self.command() if let Some(path) = &self.curr_path {
// .split(' ') if !path.cmd.is_empty() {
// .collect::<Vec<_>>() let command_path = &path.exe;
// .first()
// .map(|x| x.to_string()) if let Some(command_name) = command_path.file_name() {
// .unwrap_or_default() command_name.to_string_lossy().to_string()
self.command_only() } else {
command_path.to_string_lossy().to_string()
}
} else {
String::from("")
}
} else {
String::from("")
}
} }
/// Full name of command, with arguments /// Full name of command, with arguments
@ -325,19 +333,6 @@ impl ProcessInfo {
} }
} }
/// Full name of comand only
pub fn command_only(&self) -> String {
if let Some(path) = &self.curr_path {
if !path.cmd.is_empty() {
path.exe.to_string_lossy().to_string()
} else {
String::from("")
}
} else {
String::from("")
}
}
/// Get the status of the process /// Get the status of the process
pub fn status(&self) -> String { pub fn status(&self) -> String {
let mut state = 7; let mut state = 7;