Search code examples
bashubuntuinstallationpgipgi-accelerator

Bash error - binary operator expected


I am trying to install PGI Compilers 2016 and after running the install file I get an error:

binary operator expected

on the line:

if test -d $DIR/install_components ; then

ShellCheck.net says "add double quote to prevent globbing and word splitting" whatever it means.

But the whole installation suite is quite big, so am I supposed to add quotes in zillion places or is there some command I may use to go around it?


Solution

  • If $DIR contains spaces, the command will fail, because the variable will be expanded into two arguments.

    If you know your $DIR will never contain a space, you can safely ignore that. The best would be to report the issue with the package maintainer.

    Note that this could do very harmful things to your computer, say your script somewhere does:

    rm $DIR
    

    and $DIR="-rf /", then this would execute the famous rm -rf /