lundi 9 juillet 2018

Fixing *.sh error line 5: [: missing `]' with spacing around brackets correct

./regen_structs_proto.sh: line 5: [: missing `]'
grep: ]: No such file or directory
./regen_structs_proto.sh: line 5: [: missing `]'
grep: ]: No such file or directory

I am getting errors like the above ones when when I run the following Bash script (line 5 is the first line of the script below):

#!/bin/sh

if [ docker --version | grep -q "Docker version" ]; then
    echo "Check that docker is installed: confirmed."
else
    if [ lsb_release -si | grep -q "Linux" ]; then
        if [ lsb_release -si | grep -q "Ubuntu" ]; then
            apt-get update;
            apt-get install -y docker;
        elif [ lsb_release -si | grep -q "Manjaro" ]; then
            sudo pacman -S --needed docker;
        else
            echo "installation for Docker is not configured for your OS, please make a pull request for https://github.com/libp2p/rust-libp2p/floodsub";
        fi
    fi
fi

How can I fix these errors? I have triple checked that the spacing around the brackets is correct.

Aucun commentaire:

Enregistrer un commentaire