1

tl;dr make is working for me, but I'm looking for the appropriate tool.

I'm currently using Makefiles as script runners for my projects. In order to standardize each project, I just create a makefile so that I can write things like:

make setup
make teardown
make execute "SOMETHING"

In this case, setup might pull and deploy a bunch of docker containers, teardown might clean them up, and execute would run a command against a container.

I'm not using make to actually build things with dependencies. This makes me think I'm just being very hacky...but hey, it's worked so far.

I don't think make is the right tool for this job, but I don't know if there's some other common binary that allows people to just run xyz command, where xyz would be make in this case. I don't want to write a new bash script for every project, since that's generally much less readable imo.

Things I don't like are when make spits out:

make: *** No rule to make target FOO. Stop.

This is usually when I abuse make to process args (e.g. make execute "do this in a container").

Does anyone have suggestions on a common unix tool that would allow me to just specify some commands to run?

closed as too broad by Scott, Mr Shunz, Christopher, msp9011, Philip Couling May 8 at 11:17

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    "Does anyone have suggestions on a common unix tool that would allow me to just specify some commands to run?" ... yes, and that is called a script. If you do the same things often, you might even be able to generate them. – Panki May 6 at 8:52
  • so, is your question "how to use targets containing spaces in GNU make?" – mosvy May 7 at 6:30
  • Make is really powerful for dependency based scripts (recompile x if y has changed) and therefore very good at building things. If you're not particularly using this feature then the most likely answer is "any programming language". Scripting languages such as shell (bash) and python are generally the default choice for this type work. – Philip Couling May 8 at 11:16
0

You could do something simple with a script like this:

#!/bin/bash                                                                     

function execute {
    echo "Executing $1"
}

case "$1" in
    "setup" )
        echo "Setting up" ;;
    "teardown" )
        echo "Tearing down" ;;
    "execute" )
        shift
        execute "$@"
        ;;
    * )
        echo "Usage: ..."
esac

The usual caveats with shell scripts apply (take care with variable expansions, error handling).

Not the answer you're looking for? Browse other questions tagged or ask your own question.