12

Is there a generic way of running a bash script and seeing the commands that result, but not actually run the commands - i.e. a "dry run"/simulator of sorts?

I have a database install script (actually "make install" after running ./configure and make) that I wish to run, but it's installing all sorts of stuff that I don't want.

So I'd like a way to see exactly what it's going to do before I run it for real - maybe even run the commands by hand instead.

Is there any utility that can perform such a task (or anything related/similar)?

  • I think 'set -n' does something like that. Try adding -x as well. – Jeff Schaller Apr 11 '16 at 21:58
  • How do I pipe "make install" to set -n? – Vérace Apr 11 '16 at 22:23
  • bash -n make install, but from man bash: "An interactive shell may ignore this option." – pfnuesel Apr 11 '16 at 22:35
  • There is no dryrun option in bash. See also here stackoverflow.com/questions/19115156/… – pfnuesel Apr 11 '16 at 22:35
15

GNU make has an option to do a dry-run:

‘-n’

‘--just-print’

‘--dry-run’

‘--recon’

“No-op”. Causes make to print the recipes that are needed to make the targets up to date, but not actually execute them. Note that some recipes are still executed, even with this flag (see How the MAKE Variable Works). Also any recipes needed to update included makefiles are still executed.

So for your situation, just run make -n install to see the commands that make would execute.

5

Any version of make has a -n option (see POSIX description of make), but the shell has no corresponding option (see for example Show commands without executing them).

To aggravate the situation, if you happen to use automake, it pastes-in large chunks of boilerplate scripting (which its developers refer to as "recursive rules") which defeat the ability of anyone to use "make -n" and see what will happen.

Further reading:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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