Closed ngaro closed 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.
FYI: You can use test
on if
:
if test $(id -u) -eq 0; then
echo "hello"
fi
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)
This PR has the same effect as my previous PR ( #606 ).
The difference: It uses
test something
to check conditions instead ofif [[ 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 atest
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