5 ms·
if [ "$(uname -s)" == "Linux” ]; then stuff-goes-here else # Assume MacOS While probably true for most folks, that’s hardly what I’d call great fo
by koolba 2y ago
if [ "$(uname -s)" == "Linux” ]; then
stuff-goes-here
else # Assume MacOS
While probably true for most folks, that’s hardly what I’d call great for everybody not on Linux or a Mac.
- dspillett 2y agoThe following check for gtimeout means that other OSs that don't have the expected behaviour in either command won't break the script, you'll just get a warning message that isn't terribly relevant to them (but more helpful than simply failing or silently running without timeout/gtimeout. Perhaps improving that message would be the better option. Though for that snippet I would argue for testing for the command rather than the OS (unless Macs or some other common arrangement has something incompatible in the standard path with the same command name?).
- teo_zero 2y agoThe worst part is that if you're not running Linux but have a perfectly working 'timeout' command, the script will ignore it and fail.
- klysm 2y agoGotta draw a line somewhere
- edflsafoiewq 2y agoYeah, but you could at least elif is mac then ... else unsupported end.
- dspillett 2y agoIf you look at the next couple of lines of the code, it emits a warning if neither command is found, but carries on. Running without in this case works but it's not optimal, as described in the warning message.
- sgarland 2y agoEh. It’s true for most, and if not, it’s probably still a *BSD, so there’s a good chance that anything written for a Mac will still work. That said, I’ve never used any of the BSDs, so I may be way off here.
- sulandor 2y agoeven a certified unix https://www.opengroup.org/openbrand/register/brand3700.htm https://www.opengroup.org/openbrand/register/brand3700.htm