How to switch to bash shell from some other shell?

2019-09-09 17:22发布

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?

标签: linux bash unix
4条回答
狗以群分
2楼-- · 2019-09-09 17:57

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.

查看更多
Summer. ? 凉城
3楼-- · 2019-09-09 18:12

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

bash envsetup.sh
查看更多
别忘想泡老子
4楼-- · 2019-09-09 18:13

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.

查看更多
唯我独甜
5楼-- · 2019-09-09 18:17

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

$ bash
$ source ./envsetup.sh
查看更多
登录 后发表回答