diff --git a/tests/test_fw_path_quoting.sh b/tests/test_fw_path_quoting.sh new file mode 100644 index 000000000..af3bc2849 --- /dev/null +++ b/tests/test_fw_path_quoting.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Regression test: the firmware path occupancy check must quote its command +# substitution so multi-word contents do not break the [[ ]] test. +set -euo pipefail + +driver_file="ubuntu22.04/nvidia-driver" + +if grep -q '\[\[ ! -z $(grep' "$driver_file"; then + echo "FAIL: unquoted command substitution in [[ ]] test remains" + exit 1 +fi + diff --git a/ubuntu22.04/nvidia-driver b/ubuntu22.04/nvidia-driver index c1acbb027..8b885341f 100755 --- a/ubuntu22.04/nvidia-driver +++ b/ubuntu22.04/nvidia-driver @@ -357,7 +357,7 @@ _load_driver() { if [[ "$set_fw_path" == "true" ]]; then echo "Configuring the following firmware search path in '$fw_path_config_file': $nv_fw_search_path" - if [[ ! -z $(grep '[^[:space:]]' $fw_path_config_file) ]]; then + if grep -q '[^[:space:]]' "$fw_path_config_file"; then echo "WARNING: A search path is already configured in $fw_path_config_file" echo " Retaining the current configuration" else