15 ms·
This. People here are acting like make is installed by default on all Linuxes, but it absolutely is not. And the various BSD makes are very different to GNU mak
by alisonatwork 4y ago
This. People here are acting like make is installed by default on all Linuxes, but it absolutely is not. And the various BSD makes are very different to GNU make.
Make portability is bad enough on UNIX-like OSes, to say nothing of what a crapshoot it is on Windows. Even if you do have make installed on Windows, there's no guarantee that what it shells to is going to be able to run all the commands people tend to put in there.
Plain old shell scripting is much more portable than make, because a shell is definitely installed on every UNIX-like OS, and there is a very clear baseline of functionality that works in every Bourne/POSIX descendant. And it's quite likely to exist on a modern Windows developer machine too because bash is bundled together with Git.
My theory of writing developer scripts is to prefer the tool that already exists in the language you're developing. Gradle for JVM, npm for Node etc. Otherwise just use shell. Make feels like wrong tool for the job.
- velcrovan 4y agoThis just in, Windows isn't UNIXy, film at 11 Let me know what shell scripting selectively builds only the artifacts whose dependencies have changed (honest question).
- crabmusket 4y ago> there is a very clear baseline of functionality that works in every Bourne/POSIX descendant Where is the best place to learn what this is? I'd love to make sure I'm writing portable shell scripts when I do have to. There's also the issue that "shell scripts" often involve using binaries which you might not even realise are binaries (is "echo" a shell builtin or a binary? I forget) and which may differ from system to system. I've been bitten by grep issues before writing scripts across Ubuntu and OSX.
- JamesonNetworks 4y agoChatGPT has done wonders for my understanding of bash. I presents me with lots of tedious things I would never spend time learning
- deleted 4y ago[deleted]
- nikvdp 4y agohttps://www.shellcheck.net/ https://www.shellcheck.net/ and it’s accompanying cmdline tool/ lsp integrations is a lifesaver for preventing that kind of thing. It’ll warn you if you’re doing anything not portable and even smartly changes it’s behavior depending whether your shebang line uses bash or sh (iirc)
- cpach 4y agoDo you need portable shell scripts though? IMHO, it really depends on the context. If I was about to ship an open source application that came bundled with some shell scripts, then I agree portability is good, so that I know the script would run for people who might not have Bash installed. But at ${DAYJOB} I much prefer to let Bash run all my scripts, and I make that explicit via ‘#!/usr/bin/env bash’. Bash is still evolving and the Bash devs are adding new features that I would miss in pure sh. Case in point: A (somewhat) reasonable way of working with arrays.