AdnanHodzic / displaylink-debian

DisplayLink driver installer for Debian and Ubuntu based Linux distributions.
https://foolcontrol.org/?p=1777
GNU General Public License v3.0
1.29k stars 229 forks source link

displaylink-debian.sh potential bugs #321

Closed shriniwas26 closed 4 years ago

shriniwas26 commented 5 years ago

Ran https://github.com/AdnanHodzic/displaylink-debian/blob/f97970c/displaylink.sh through shellcheck, please find attached.

In displaylink-debian.sh line 15:
version=`wget -q -O - https://www.displaylink.com/downloads/ubuntu | grep "download-version" | head -n 1 | perl -pe '($_)=/([0-9]+([.][0-9]+)+)/'`
        ^-- SC2006: Use $(..) instead of legacy `..`.

In displaylink-debian.sh line 17:
dlurl="https://www.displaylink.com/"`wget -q -O - https://www.displaylink.com/downloads/ubuntu | grep "download-link" | head -n 1 | perl -pe '($_)=/<a href="\/([^"]+)"[^>]+class="download-link"/'`
                                    ^-- SC2006: Use $(..) instead of legacy `..`.

In displaylink-debian.sh line 28:
sys_driver_version="$(ls /usr/src/ | grep "evdi" | cut -d "-" -f2)"
                      ^-- SC2010: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.

In displaylink-debian.sh line 53:
read key
^-- SC2162: read without -r will mangle backslashes.
     ^-- SC2034: key appears unused. Verify it or export it.

In displaylink-debian.sh line 58:
if (( $EUID != 0 ));
      ^-- SC2004: $/${} is unnecessary on arithmetic variables.

In displaylink-debian.sh line 73:
list_etc_confd=$(ls -1 $x11_etc*.conf 2>/dev/null | wc -l)
                 ^-- SC2012: Use find instead of ls to better handle non-alphanumeric filenames.

In displaylink-debian.sh line 79:
                find $x11_etc -type f -name "*.conf" | xargs echo "X11 configs:"
                                ^-- SC2038: Use -print0/-0 or -exec + to allow for non-alphanumeric filenames.

In displaylink-debian.sh line 82:
                find $x11_etc_confd -type f -name "*.conf" | xargs echo "X11 configs:"
                                ^-- SC2038: Use -print0/-0 or -exec + to allow for non-alphanumeric filenames.

In displaylink-debian.sh line 99:
for dep in ${deps[@]}
           ^-- SC2068: Double quote array expansions to avoid re-splitting elements.

In displaylink-debian.sh line 101:
    if ! dpkg -s $dep | grep "Status: install ok installed" > /dev/null 2>&1
                     ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 104:
        read -p "$dep not found! Install? [Y/n] " response
                ^-- SC2162: read without -r will mangle backslashes.

In displaylink-debian.sh line 108:
            if ! apt-get install $dep
                                             ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 153:
    if [ $codename == "trusty" ] || [ $codename == "vivid" ] || [ $codename == "wily" ] || [ $codename == "xenial" ] || [ $codename == "yakkety" ] || [ $codename == "zesty" ] || [ $codename == "artful" ] || [ $codename == "bionic" ] || [ $codename == "cosmic" ] || [ $codename == "disco" ] || [ $codename == "eoan" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                          ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                      ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                 ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                              ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                            ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                        ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                     ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                                                  ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                                                                               ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                                                                                                           ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 163:
    if [ $codename == "freya" ] || [ $codename == "loki" ] || [ $codename == "juno" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                         ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                    ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 173:
    if [ $codename == "jessie" ] || [ $codename == "stretch" ] || [ $codename == "buster" ] || [ $codename == "bullseye" ] || [ $codename == "sid" ] || [ $codename == "n/a" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                          ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                        ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                     ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                    ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                              ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 193:
    if [ $codename == "sarah" ] || [ $codename == "rosa" ] || [ $codename == "petra" ] || [ $codename == "olivia" ] || [ $codename == "serena" ] || [ $codename == "sonya" ] || [ $codename == "sylvia" ] || [ $codename == "tara" ] || [ $codename == "tessa" ] || [ $codename == "betsy" ] || [ $codename == "cindy" ] || [ $codename == "tina" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                         ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                    ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                          ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                      ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                   ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                                              ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                                                                          ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                                                                                                      ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                                                                                                                                                                                  ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 204:
    if [ $codename == "kali-rolling" ] || [ $codename == "2016.2" ] || [ $codename == "2017.3" ] || [ $codename == "2018.3" ] || [ $codename == "2018.4" ] || [ $codename == "n/a" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                          ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                       ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                                                    ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 214:
    if [ $codename == "unstable" ] || [ $codename == "stable" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                            ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 224:
    if [ $codename == "Horizon" ] || [ $codename == "Continuum" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.
                                           ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 234:
    if [ $codename == "helium" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 244:
    if [ $codename == "n/a" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 263:
    if [ $codename == "trusty" ];
             ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 270:
    if [ $codename == "freya" ];
         ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 301:
cd - &> /dev/null
^-- SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

In displaylink-debian.sh line 309:
if [ -d $driver_dir ]
        ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 312:
    rm -r $driver_dir
              ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 321:
read -p "Reboot now? [Y/n] " ack
^-- SC2162: read without -r will mangle backslashes.

In displaylink-debian.sh line 324:
for letter in "$ack"; do
              ^-- SC2066: Since you double quoted this, it will not word split, and the loop will only run once.

In displaylink-debian.sh line 339:
local dlfileid=$(echo $dlurl | perl -pe '($_)=/.+\?id=(\d+)/')
      ^-- SC2155: Declare and assign separately to avoid masking return values.
                      ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 343:
read ACCEPT
^-- SC2162: read without -r will mangle backslashes.

In displaylink-debian.sh line 348:
                wget -O DisplayLink_Ubuntu_${version}.zip "--post-data=fileId=$dlfileid&accept_submit=Accept" $dlurl
                                                           ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                              ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 350:
                if [ $? -ne 0 ]
                                     ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

In displaylink-debian.sh line 368:
mkdir $driver_dir
      ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 372:
test -d $driver_dir && /bin/rm -Rf $driver_dir
        ^-- SC2086: Double quote to prevent globbing and word splitting.
                                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 373:
unzip -d $driver_dir DisplayLink_Ubuntu_${version}.zip
         ^-- SC2086: Double quote to prevent globbing and word splitting.
                                        ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 374:
chmod +x $driver_dir/displaylink-driver-${version}.[0-9]*.run
         ^-- SC2086: Double quote to prevent globbing and word splitting.
                                        ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 375:
./$driver_dir/displaylink-driver-${version}.[0-9]*.run --keep --noexec
  ^-- SC2086: Double quote to prevent globbing and word splitting.
                                 ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 376:
mv displaylink-driver-${version}.[0-9]*/ $driver_dir/displaylink-driver-${version}
                      ^-- SC2086: Double quote to prevent globbing and word splitting.
                                         ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                        ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 382:
sed -i "s/SYSTEMINITDAEMON=unknown/SYSTEMINITDAEMON=$sysinitdaemon/g" $driver_dir/displaylink-driver-${version}/displaylink-installer.sh
                                                                      ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                     ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 387:
    sed -i 's#/lib/modules/$KVER/build/Kconfig#/lib/modules/$KVER/build/scripts/kconfig/conf#g' $driver_dir/displaylink-driver-${version}/displaylink-installer.sh
               ^-- SC2016: Expressions don't expand in single quotes, use double quotes for that.
                                                                                                    ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                                                                                                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 388:
    ln -s /lib/modules/$(uname -r)/build/Makefile /lib/modules/$(uname -r)/build/Kconfig
                           ^-- SC2046: Quote this to prevent word splitting.
                                                                   ^-- SC2046: Quote this to prevent word splitting.

In displaylink-debian.sh line 395:
cd $driver_dir/displaylink-driver-${version}
^-- SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
   ^-- SC2086: Double quote to prevent globbing and word splitting.
                                  ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 399:
kernel_check="$(uname -r | egrep -o '[0-9]+\.[0-9]+')"
                           ^-- SC2196: egrep is non-standard and deprecated. Use grep -E instead.

In displaylink-debian.sh line 428:
if [ "$(ver2int $kernel_check)" -ge "$(ver2int '4.14.9')" ];
                ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 458:
    echo "Copying init script to /etc/init.d\n"
          ^-- SC2028: echo won't expand escape sequences. Consider printf.

In displaylink-debian.sh line 652:
                if [ "$(ver2int $xorg_vcheck)" -gt "$(ver2int $newgen_xorg)" ];
                                                ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 665:
        if [ "$(ver2int $xorg_vcheck)" -gt "$(ver2int $newgen_xorg)" ];
                                ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 684:
if [ "$(ver2int $xorg_vcheck)" -gt "$(ver2int $min_xorg)" ];
                ^-- SC2086: Double quote to prevent globbing and word splitting.

In displaylink-debian.sh line 701:
    rm /lib/modules/$(uname -r)/build/Kconfig
                        ^-- SC2046: Quote this to prevent word splitting.

In displaylink-debian.sh line 712:
bash /opt/displaylink/displaylink-installer.sh uninstall && 2>&1>/dev/null
                                                            ^-- SC2069: The order of the 2>&1 and the redirect matters. The 2>&1 has to be last.
                                                            ^-- SC2188: This redirection doesn't have a command. Move to its command (or use 'true' as no-op).

In displaylink-debian.sh line 735:
read -p "Did you read Post Installation Guide? http://bit.ly/2TbZleK [y/N] " ack
^-- SC2162: read without -r will mangle backslashes.

In displaylink-debian.sh line 738:
for letter in "$ack"; do
              ^-- SC2066: Since you double quoted this, it will not word split, and the loop will only run once.

In displaylink-debian.sh line 752:
read -p "Did you read Troubleshooting most common issues? http://bit.ly/2Rofd0x [y/N] " ack
^-- SC2162: read without -r will mangle backslashes.

In displaylink-debian.sh line 755:
for letter in "$ack"; do
              ^-- SC2066: Since you double quoted this, it will not word split, and the loop will only run once.

In displaylink-debian.sh line 800:
read -p "[I]nstall
^-- SC2162: read without -r will mangle backslashes.
Barabazs commented 4 years ago

You're always welcome to propose changes and send a merge request.