Skip to content

fix: deprecated '[ ! -z ... ]' instead of '-n' - #951

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/nvidia-driver-deprecated-z-instead-of-n
Open

fix: deprecated '[ ! -z ... ]' instead of '-n'#951
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/nvidia-driver-deprecated-z-instead-of-n

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in ubuntu24.04/nvidia-driver: deprecated '[ ! -z ... ]' instead of '-n'.

Changes

  • ubuntu24.04/nvidia-driver: deprecated '[ ! -z ... ]' instead of '-n'.

Details

--- a/ubuntu24.04/nvidia-driver
+++ b/ubuntu24.04/nvidia-driver
@@ -76,7 +76,7 @@ _cleanup_package_cache() {
 }
 
 _update_ca_certificates() {
-    if [ ! -z "$(ls -A /usr/local/share/ca-certificates)" ]; then
+    if [ -n "$(ls -A /usr/local/share/ca-certificates)" ]; then
         update-ca-certificates
     fi
 }
@@ -401,7 +401,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 [[ -n $(grep '[^[: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

Tests

  • tests/test_no_deprecated_not_z.sh
--- /dev/null
+++ tests/test_no_deprecated_not_z.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -eu
+
+DRIVER_FILE="ubuntu24.04/nvidia-driver"
+
+if grep -F '[ ! -z ' "$DRIVER_FILE"; then
+    echo "FAIL: deprecated '[ ! -z ... ]' still present" >&2
+    exit 1
+fi
+
+if grep -F '[[ ! -z ' "$DRIVER_FILE"; then
+    echo "FAIL: deprecated '[[ ! -z ... ]]' still present" >&2
+    exit 1
+fi
+
+echo "PASS: no deprecated '[ ! -z ... ]' tests"

Contributor guidelines

Per this repo's CONTRIBUTING.md:

  • All commits are signed off (Signed-off-by trailer, DCO).

@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant