Nyr / openvpn-install

OpenVPN road warrior installer for Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS and Fedora
MIT License
19.1k stars 4.9k forks source link

Consider using ShellCheck for the Bash script #1053

Closed lisenet closed 11 months ago

lisenet commented 1 year ago

It may be worth running shellcheck against openvpn-install.sh.

Nyr commented 11 months ago

I already use it.

lisenet commented 11 months ago

Are you sure @Nyr?

In tmp line 15:
read -N 999999 -t 0.001
^--^ SC2162: read without -r will mangle backslashes.

In tmp line 67:
    echo '$PATH does not include sbin. Try using "su -" instead of "su".'
             ^-- SC2016: Expressions don't expand in single quotes, use double quotes for that.

In tmp line 119:
        read -p "IPv4 address [1]: " ip_number
                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 122:
            read -p "IPv4 address [1]: " ip_number
                        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 133:
        read -p "Public IPv4 address / hostname [$get_public_ip]: " public_ip
                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 137:
            read -p "Public IPv4 address / hostname: " public_ip
                        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 151:
        read -p "IPv6 address [1]: " ip6_number
                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 154:
            read -p "IPv6 address [1]: " ip6_number
                        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 163:
    read -p "Protocol [1]: " protocol
        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 166:
        read -p "Protocol [1]: " protocol
                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 178:
    read -p "Port [1194]: " port
        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 181:
        read -p "Port [1194]: " port
                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 192:
    read -p "DNS server [1]: " dns
        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 195:
        read -p "DNS server [1]: " dns
                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 199:
    read -p "Name [client]: " unsanitized_client
        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 201:
    client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client")
                 ^-- SC2001: See if you can use ${variable//search/replace} instead.

In tmp line 243:
    cd /etc/openvpn/server/easy-rsa/
        ^-- SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

Did you mean: 
    cd /etc/openvpn/server/easy-rsa/ || exit

In tmp line 299:
            grep -v '^#\|^;' "$resolv_conf" | grep '^nameserver' | grep -v '127.0.0.53' | grep -oE '[0-9]{1,3}(\.[0-9]{1,3}){3}' | while read line; do
                                                                                                                                                     ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 447:
    read -p "Option: " option
        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 450:
        read -p "Option: " option
                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 456:
            read -p "Name: " unsanitized_client
                        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 457:
            client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client")
                                 ^-- SC2001: See if you can use ${variable//search/replace} instead.

In tmp line 460:
                read -p "Name: " unsanitized_client
                                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 461:
                client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client")
                                         ^-- SC2001: See if you can use ${variable//search/replace} instead.

In tmp line 463:
            cd /etc/openvpn/server/easy-rsa/
                        ^-- SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

Did you mean: 
            cd /etc/openvpn/server/easy-rsa/ || exit

In tmp line 483:
            read -p "Client: " client_number
                        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 486:
                read -p "Client: " client_number
                                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 490:
            read -p "Confirm $client revocation? [y/N]: " revoke
                        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 493:
                read -p "Confirm $client revocation? [y/N]: " revoke
                                ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 496:
                cd /etc/openvpn/server/easy-rsa/
                                ^-- SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

Did you mean: 
                cd /etc/openvpn/server/easy-rsa/ || exit

In tmp line 513:
            read -p "Confirm OpenVPN removal? [y/N]: " remove
                        ^--^ SC2162: read without -r will mangle backslashes.

In tmp line 516:
                read -p "Confirm OpenVPN removal? [y/N]: " remove
                                ^--^ SC2162: read without -r will mangle backslashes.

For more information:
  https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |...
  https://www.shellcheck.net/wiki/SC2016 -- Expressions don't expand in singl...
  https://www.shellcheck.net/wiki/SC2162 -- read without -r will mangle backs...
Nyr commented 11 months ago

Yes. And I will not go into a useless discussion with someone who clearly does not understand the context and/or the warnings.

lisenet commented 11 months ago

Why so defensive? I must have struck a nerve or something.