Bash script says version is not supported, even though it is
Created by: ggerganov
I observe the following issue:
$ ./patch.sh
Detected nvidia driver version: 396.54
Patch for this (396.54) nvidia driver not found.
Available patches for:
390.87
396.26
396.24
410.48
415.25
415.18
375.39
410.57
410.73
396.54
410.78
410.79
396.37
Notice that the 396.54
is supported. However the script aborts with error.
$ lsb_release --all
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.3 LTS
Release: 12.04
Codename: precise
$ bash --version
GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
I'm not a bash expert, but I was able to fix this with the following patch:
$ git diff
diff --git a/patch.sh b/patch.sh
index 907225b..2a7550a 100755
--- a/patch.sh
+++ b/patch.sh
@@ -79,7 +79,7 @@ fi
echo "Detected nvidia driver version: $driver_version"
-if [[ ! -v "patch_list[$driver_version]" || ! -v "object_list[$driver_version]" ]]; then
+if [[ ! "${patch_list[$driver_version]+isset}" || ! "${object_list[$driver_version]+isset}" ]]; then
echo "Patch for this ($driver_version) nvidia driver not found." 1>&2
echo "Available patches for: " 1>&2
for drv in "${!patch_list[@]}"; do
Now it works flawlessly.