Command that exits with zero status (not /bin/true)?

Even though you've asked for something that is "not /bin/true", replacing true with the full name /bin/true to show that it is the true program rather than some other meaning of "true" is probably the best solution.

Your concern is that the true in

make TOOL=true

appears to be something other than a command name. But if you write

make TOOL=/bin/true

then that is unambiguously a command. Somebody might misread TOOL=true to mean that some other tool somewhere is intended, but no such misreading of TOOL=/bin/true is likely.


I am unsure as to when :, which is a shell builtin but not an external command, will work. Henning Makholm has reported that it appears to work. But I think it does not work in all situations, and you found that it did not work for you.

As for a shell alias, you cannot use that because alias expansion is not performed in the arguments you pass to a command, nor do makefiles make any use of previously defined shell aliases. Even if make runs your commands in a new shell, that shell will not have the alias (and would not use it even if it did have it, because it would be a noninteractive shell, where alias expansion is not automatically enabled).


While I agree that using the full path to true would be the best solution, I'd like to note what's probably by far the most common way to avoid real command execution: sticking an echo in front of it. So:

make TOOL=echo

You can always make your own command that does nothing but return a zero exit status. Some options:

  • an appropriately named symbolic link to /bin/true

  • an empty shell script

  • a nearly empty C program:

    int main() {
        return 0;
    }
    

Tags:

Command Line