I've spent the last couple of weeks playing the "front end build tool dance" (primarily a back end dev) to find a system I like and it simply never occurred to me I could write my own as a quick bash script or python if I think it'll grow.
That's an embarrassing oversight.
Shell is also significantly easier and faster, if you just want to say run jslint, then minify, etc.
I program in lots of languages, so shell is the first tool I reach for. Learning the language is enough; I don't have time for all these quirky build and deploy tools.
Gruntfiles and Gulpfiles are in javascript too, which lowers the barrier for entry for developers who aren't as versed in linux.
Is there a shell script equivalent to npm? Sidenote, that could be really useful as a service.
On your own stack and dev environment, why would you care about compatibility of shell scripts? Do you change your stack much?
make deploy SERVER=example.com
Shell syntax is horrible itself. Make doesn't add too much on top of that.A shell script cannot adequately express task dependencies, or one that did would become a build tool like make. As it stands, make has a very simple and light syntax for expressing dependencies and has remained useful with little modification for quite some time.
Make isn't necessarily the best automation tool, but it's a great build tool.
Make is a non-procedural way to describe the dependencies of your build process. You describe what you want as a result rather than the steps that the interpreter should follow.
It's possible to like or dislike this approach but it's clearly qualitatively different from Shell scripting.
Make basically adds a very small "declarative" dependency layer, and then reimplements the shell poorly:
- variables (from the environment)
- command tokenization
- escaping rules
- functions
- if statements
- include
- globbing (in the target line)
- various magic $ variables
- process substitution
- eval
... etc.
That is, it's a full fledged programming language with different syntax than shell, but mostly the same features. I guess what might do in some cases is have a very simple "actions.sh" shell script, and then a Makefile which ONLY has simple command lines calling into actions.sh. Any functions would be in bash rather than make.This is actually nice because there is an "upgrade path". For most simple things, you can just stick with shell. But when you need the power of make, you can upgrade without rewriting anything -- just adding a short/readable makefile.
run.sh
build() {
...
}
test() {
...
}
deploy() {
...
}
# This lets you do ./run.sh build foo bar at the command
# line. The autocomplete scans for functions in .sh files
# and fills them in as the first arg.
"$@"
The only case where you really need the incremental behavior of Make is C/C++ builds (and arguably it's increasingly inappropriate for this domain as well). For all other kinds of automation I just use shell scripts, since Make is mostly a horribly reinvented shell script dialect.