SpaceinvaderOne / Dump_GPU_vBIOS

Script to dump the vbios from any GPU even if primary gpu on an Unraid Server
147 stars 45 forks source link

Shellcheck reports Warnings #6

Open laywill opened 3 years ago

laywill commented 3 years ago

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 https://github.com/SpaceinvaderOne/Dump_GPU_vBIOS/commit/963677c5b4ddedd9ba78fd056f693382853287a0 . 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" "

$