Skip to content

Commit

Permalink
Chamges in parsing of line with process (imgPath and vmPath)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bajger committed Jan 7, 2024
1 parent 67b21fe commit 4a63427
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/PharoLauncher-CLI/PhLImageProcessListCliCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ PhLImageProcessListCliCommand >> processListCmdArgs [
nextPutAll: self currentVMPid asString;
nextPutAll: ' | while read -r line; do'; lf;
nextPutAll: ' pid=$(echo "$line" | awk ''{print $1}'')'; lf;

"These sed commands are more permissive and should handle cases where vmPath or imgPath contains arbitrary arguments or flags."
nextPutAll: ' vmPath=$(echo "$line" | sed -E ''s/^[0-9]+ (.+\.image)/\1/'' | awk ''{print $1}'')'; lf;
nextPutAll: ' imgPath=$(echo "$line" | sed -E ''s/^[0-9]+.+\.image (.+)/\1/'' | awk ''{print $1}'')'; lf;

"This captures the entire cmd line (excluding the PID) and stores it in the cmd variable"
nextPutAll: ' cmd=$(echo "$line" | cut -d'' '' -f2-)'; lf;

"This extracts the vmPath by capturing everything up to the first occurrence of .image."
nextPutAll: ' vmPath=$(echo "$cmd" | sed -E ''s/([^ ]+\.image).*/\1/'')'; lf;

"This extracts the imgPath by capturing everything after .image."
nextPutAll: ' imgPath=$(echo "$cmd" | sed -E ''s/[^ ]+\.image (.*)/\1/'')'; lf;

nextPutAll: ' start_time=$(ps -o lstart= -p "$pid")'; lf;
nextPutAll: ' echo "$pid'; << separator; << '$vmPath'; << separator; << '$imgPath'; << separator; << '$start_time"'; lf;
nextPutAll: 'done'
Expand Down

0 comments on commit 4a63427

Please sign in to comment.