How to switch to bash shell from some other shell?

2019-09-09 17:34发布

问题:

I am running a shell script "envsetup.sh" and I keep getting the following error.

Badly placed ()'s

I found out the error is because I am not in a bash shell environment. Can anyone help explain how to enter the bash shell environment?

回答1:

Assuming you are trying to compile Android, you can do the following to temporarily use bash:

$ bash
$ source ./envsetup.sh


回答2:

To switch to a bash login shell (which reads profiles etc), you should type:

exec bash -l

The -l option indicates that it should be a login shell. You can then read the envsetup.sh file using:

source envsetup.sh

You may be able to use the chsh command to change your login shell permanently using a line such as:

chsh /bin/bash

Just make sure the name you specify is the correct path to your copy of bash.



回答3:

Try putting the line:

#!/bin/bash

as the first line of your script. I am assuming the bash command file is in /bin - if not have a look for where it is located and use that path instead.



回答4:

to run a single script envsetup.sh in bash, invoke it like this:

bash envsetup.sh


标签: linux bash unix