3 ms·
I'm not sure why does this crazy "x" prefix tale still continue. You can simply quote them instead. Especially if you use bash and not some other sh-compatible
by viraptor 12y ago
I'm not sure why does this crazy "x" prefix tale still continue. You can simply quote them instead. Especially if you use bash and not some other sh-compatible shell:
if [ "$1" == "$2" ];
will work just fine.
If you need all sh compatibility, it should be test for "x$1" anyway (still quoted).
- Arkanosis 12y agoI think you meant “=”, not “==” (though the latter would work with bash).
- viraptor 12y agoWell, either in the example. Parent was saying "Reminds me on bash" For sh version, I'd go with super-safe: if test "x$1" = "x$2"
- seanp2k2 12y agoIf you're doing that, even better to use "x${1}" to be safer. Also, conditional expressions ( [[ instead of [ or `test`) are generally a bit more well-behaved. See http://wiki.bash-hackers.org/syntax/ccmd/conditional_expression http://wiki.bash-hackers.org/syntax/ccmd/conditional_express... for more info.
- viraptor 12y agoBut [[ is a bashism - it won't work on bare sh.