I thought that make interprets the rule's set of commands literally, passing them to the sub-shell. But this doesn't seem to work in this case:

default: loop
        echo $$RANDOM 

This prints echo $RANDOM in my shell but doesn't actually print the number.


GNU make: Choosing the shell says that the default shell is /bin/sh.

$RANDOM is a bash feature, so you could explicitly tell make to use bash by putting

SHELL := '/bin/bash'

at the top of your Makefile.

(echo $RANDOM is just make echoing the command it's going to run.)

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.