w: add --pids option to display the pid of the login and best processes.

This commit is contained in:
Jan Pazdziora
2022-06-22 12:07:55 +02:00
committed by Craig Small
parent 3cfe83a25c
commit 5baf1e6226
3 changed files with 39 additions and 8 deletions

View File

@@ -17,10 +17,12 @@ set w_login "\(\\d+\[A-Z\]\[a-z\]{2}\\d+\|\[A-Z\]\[a-z\]{2}\\d+\|\\d+:\\d+\)"
set w_idle "\(\\?xdm\\?\|\\?\|\\d+days\|\\d+:\\d+m?\|\\d+.\\d+s\)"
set w_ival7 "\(\\?\|\\d+days\|\\d+:\\d+m?\|\\d+.\\d+s\)"
set w_what "\[A-Za-z0-9_\/\\-\]+"
set w_pids "\\d+/\\d+"
set w_std_userlines "\(${w_user}\\s+${w_tty}\\s+${w_login}\\s+${w_idle}\\s+${w_ival7}\\s+${w_ival7}\\s+${w_what}\\s*\)*"
set w_short_userlines "\(${w_user}\\s+${w_tty}\\s+${w_idle}\\s+${w_what}\\s*\)*"
set w_from_userlines "\(${w_user}\\s+${w_tty}\\s+${w_from}\\s+${w_login}\\s+${w_idle}\\s+${w_ival7}\\s+${w_ival7}\\s+${w_what}\\s*\)*"
set w_fromshort_userlines "\(${w_user}\\s+${w_tty}\\s+${w_from}\\s+${w_idle}\\s+${w_what}\\s*\)*"
set w_pid_userlines "\(${w_user}\\s+${w_tty}\\s+${w_idle}\\s+%{w_pids}\s+${w_what}\\s*\)*"
set test "w with no arguments"
spawn $w
@@ -51,3 +53,7 @@ set test "w with short and from flags"
spawn $w -sf
expect_pass "$test" "^${w_fromshort_header}${w_fromshort_userlines}"
set test "w with pids display"
spawn $w -p
expect_pass "$test" "^${w_std_header}${w_pid_userlines}"