From b92a4270f1a6b32d5f80780ccdbab7bb8d014a0c Mon Sep 17 00:00:00 2001 From: escapefreeg <42019181+escapefreeg@users.noreply.github.com> Date: Sun, 11 Aug 2024 10:56:19 +0800 Subject: [PATCH] optimize the logic for detecting the FreeRDP command --- bin/winapps | 16 ++++++++++------ installer.sh | 15 ++++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/bin/winapps b/bin/winapps index b5250a3..6aed16a 100755 --- a/bin/winapps +++ b/bin/winapps @@ -250,12 +250,16 @@ function waGetFreeRDPCommand() { if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then FREERDP_COMMAND="xfreerdp" fi - # Check for 'xfreerdp3'. - elif command -v xfreerdp3 &>/dev/null; then - # Check FreeRDP major version is 3 or greater. - FREERDP_MAJOR_VERSION=$(xfreerdp3 --version | head -n 1 | grep -o -m 1 '\b[0-9]\S*' | head -n 1 | cut -d'.' -f1) - if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then - FREERDP_COMMAND="xfreerdp3" + fi + + # Check for 'xfreerdp3' command as a fallback option. + if [ -z "$FREERDP_COMMAND" ]; then + if command -v xfreerdp3 &>/dev/null; then + # Check FreeRDP major version is 3 or greater. + FREERDP_MAJOR_VERSION=$(xfreerdp3 --version | head -n 1 | grep -o -m 1 '\b[0-9]\S*' | head -n 1 | cut -d'.' -f1) + if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then + FREERDP_COMMAND="xfreerdp3" + fi fi fi diff --git a/installer.sh b/installer.sh index 554a373..a27d0ce 100755 --- a/installer.sh +++ b/installer.sh @@ -548,11 +548,16 @@ function waCheckInstallDependencies() { if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then FREERDP_COMMAND="xfreerdp" fi - elif command -v xfreerdp3 &>/dev/null; then - # Check FreeRDP major version is 3 or greater. - FREERDP_MAJOR_VERSION=$(xfreerdp3 --version | head -n 1 | grep -o -m 1 '\b[0-9]\S*' | head -n 1 | cut -d'.' -f1) - if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then - FREERDP_COMMAND="xfreerdp3" + fi + + # Check for xfreerdp3 command as a fallback option. + if [ -z "$FREERDP_COMMAND" ]; then + if command -v xfreerdp3 &>/dev/null; then + # Check FreeRDP major version is 3 or greater. + FREERDP_MAJOR_VERSION=$(xfreerdp3 --version | head -n 1 | grep -o -m 1 '\b[0-9]\S*' | head -n 1 | cut -d'.' -f1) + if [[ $FREERDP_MAJOR_VERSION =~ ^[0-9]+$ ]] && ((FREERDP_MAJOR_VERSION >= 3)); then + FREERDP_COMMAND="xfreerdp3" + fi fi fi