Ultimate-Hosts-Blacklist / Ultimate.Hosts.Blacklist

The Ultimate Unified Hosts file for protecting your network, computer, smartphones and Wi-Fi devices against millions of bad web sites. Protect your children and family from gaining access to bad web sites and protect your devices and pc from being infected with Malware or Ransomware.
MIT License
1.24k stars 155 forks source link

No square brackets #607

Closed ngaro closed 3 years ago

ngaro commented 3 years ago

This PR has the same effect as my previous PR ( #606 ).

The difference: It uses test something to check conditions instead of if [[ something ]] ; then ... ; fi

Although this is my own PR, I actually don't like it.

It's safe to assume a system where the shell does not support [[ ]] is equally as rare as a system where a test shell-builtin and/or binary isn't available. But the one with the square brackets is more clear so I suggest closing this one and merging #606.

The only reason I opened this PR is because of rusty-snake's comment in #605

rusty-snake commented 3 years ago

[ is POSIX compliant (https://pubs.opengroup.org/onlinepubs/009695399/utilities/test.html), so if [ "$(id -u)" -eq 0 ]; then … should work for any POSIX system.

rusty-snake commented 3 years ago

FYI: You can use test on if:

if test $(id -u) -eq 0; then
    echo "hello"
fi
ngaro commented 3 years ago

Really ? I did not know that ! In that case I'm closing #607 (but i'll use [] instead of test so that we don't have to rely on it's existence)