From 7b4b1d631227f3a009a025a861cf5e92cbc4689f Mon Sep 17 00:00:00 2001 From: Petros Amoiridis Date: Thu, 20 Apr 2023 20:06:33 +0300 Subject: [PATCH] Use regex to make extraction bulletproof --- script/start-local-collaboration | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/start-local-collaboration b/script/start-local-collaboration index 7a94982a5a..5ac440eda2 100755 --- a/script/start-local-collaboration +++ b/script/start-local-collaboration @@ -33,9 +33,9 @@ fi # Make each Zed instance take up half of the screen. output=$(system_profiler SPDisplaysDataType -json) resolution=$(echo "$output" | jq -r '.SPDisplaysDataType[0].spdisplays_ndrvs[] | select(.spdisplays_online == "spdisplays_yes") | ._spdisplays_resolution') -width=$(echo "$resolution" | jq -Rr 'split(" x ")[0]') +width=$(echo "$resolution" | jq -Rr 'match("(\\d+) x (\\d+)").captures[0].string') half_width=$(($width / 2)) -height=$(echo "$resolution" | jq -Rr 'split(" x ")[1]') +height=$(echo "$resolution" | jq -Rr 'match("(\\d+) x (\\d+)").captures[1].string') y=0 echo "Width: $width"