SpaceinvaderOne / Dump_GPU_vBIOS

Script to dump the vbios from any GPU even if primary gpu on an Unraid Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shellcheck reports Warnings

laywill opened this issue · comments

commented

Hi,

Really helpful work that has made this process a lot easier! Thanks!

In the spirit of giving back I wanted to take the time to see if I could help improve things to minimise any potential issues for others using the script. Running Shellcheck on dump_vbios.sh produces a number of warnings as of commit 963677c . The output from Shellcheck is listed below.

$ shellcheck dump_vbios.sh
 
Line 35:
gpuid=$(echo "$gpuid" | sed 's/ *$//')
        ^-- SC2001: See if you can use ${variable//search/replace} instead.
 
Line 37:
gpuid=$(echo "$gpuid" | sed 's/^ *//g')
        ^-- SC2001: See if you can use ${variable//search/replace} instead.
 
Line 41:
mygpu=$(lspci -s $gpuid)
                 ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
mygpu=$(lspci -s "$gpuid")
 
Line 43:
disconnectid=$(echo "$dumpid" | sed 's?:?\\:?g')
               ^-- SC2001: See if you can use ${variable//search/replace} instead.
 
Line 45:
disconnectid2=$(echo "$disconnectid" | sed 's/\(.*\)0/\11/')
^-- SC2034: disconnectid2 appears unused. Verify use (or export if used externally).
                ^-- SC2001: See if you can use ${variable//search/replace} instead.
 
Line 55:
        mygpu=$(lspci -s $gpuid) || { notvalidpci; exit; }
                         ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
        mygpu=$(lspci -s "$gpuid") || { notvalidpci; exit; }
 
Line 196:
                        echo "Vbios folder created at "$mountlocation" "
                                                       ^-- SC2027: The surrounding quotes actually unquote this. Remove or escape them.
                                                       ^-- SC2154: mountlocation is referenced but not assigned.
                                                       ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
                        echo "Vbios folder created at ""$mountlocation"" "
 
Line 200:
                        echo "Vbios folder "$mountlocation" already exists"
                                            ^-- SC2027: The surrounding quotes actually unquote this. Remove or escape them.
                                            ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
                        echo "Vbios folder ""$mountlocation"" already exists"
 
Line 249:
                        echo "1" | tee -a /sys/bus/pci/devices/$disconnectid/remove
>>                                                             ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
                        echo "1" | tee -a /sys/bus/pci/devices/"$disconnectid"/remove
 
Line 268:
                        echo "forcereset is set as "$forcereset" this is not a recognised option"
                                                    ^-- SC2027: The surrounding quotes actually unquote this. Remove or escape them.
 
Line 297:
        cd /sys/bus/pci/devices/"$dumpid"/
        ^-- SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

Did you mean: (apply this, apply all SC2164)
        cd /sys/bus/pci/devices/"$dumpid"/ || exit
 
Line 300:
        echo "Okay dumping vbios file named "$vbiosname" to the location "$vbioslocation" "
                                             ^-- SC2027: The surrounding quotes actually unquote this. Remove or escape them.
                                             ^-- SC2086: Double quote to prevent globbing and word splitting.
>>                                                                        ^-- SC2027: The surrounding quotes actually unquote this. Remove or escape them.

Did you mean: (apply this, apply all SC2086)
        echo "Okay dumping vbios file named ""$vbiosname"" to the location "$vbioslocation" "

$