Force gmake to excute under bash instead of sh

bejhan
bejhan used Ask the Experts™
on
How can I force gmake to execute under bash instead of sh?


I have tried entering a bash shell (by typing bash), but gmake still uses sh.
I have tried aliasing sh to bash, same result.
I have tried adding #!/bin/sh to the top of the make file, same result.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2013
Top Expert 2013

Commented:
Did you try

export SHELL=/bin/bash

?

Author

Commented:
Just tries, doesn't seem to work:

jetha@mustang(inhouse)> gmake
/bin/sh: syntax error at line 1: `(' unexpected
gmake: *** [obj/util/arena.o] Error 2
jetha@mustang(inhouse)> export SHELL=/bin/bash
jetha@mustang(inhouse)> echo $SHELL
/bin/bash
jetha@mustang(inhouse)> gmake
/bin/sh: syntax error at line 1: `(' unexpected
gmake: *** [obj/util/arena.o] Error 2

Open in new window

Author

Commented:
After using the truss command to investigate what is going on with gmake, I see that gmake actually executes bin/sh on its own so I do not think there is a way to change the shell used without recompile gmake.

Author

Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for bejhan's comment http:/Q_27241012.html#36318519

for the following reason:

Found own solution.
Most Valuable Expert 2013
Top Expert 2013
Commented:
I think there is a way!

Add to your Makefile

SHELL = /bin/bash
export SHELL

I forgot that with GNU male the SHELLvariable is not taken from the user's environment!

wmp

Author

Commented:
You are correct! I was hasty in closing this question.

I see why they call you a genius ;)
Most Valuable Expert 2013
Top Expert 2013

Commented:
Since there are two "flavors" of variables in the Makefile, you can also try

SHELL := /bin/bash
export SHELL

Author

Commented:
Thank you! I have been trying to get this library to compile for days!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial