Баш больше не работает?

631
verity1007

Я пытался установить home brew (я новичок в командной строке и следовал некоторым учебникам о том, как начать работу с github).

Поэтому я следовал этому неофициальному методу обновления: скомпилируйте Bash из исходного кода, используя Homebrew ( https://security.stackexchange.com/questions/68202/how-to-patch-bash-on-osx-in-wake-of-shellshock )

Вот что я набрал в Терминале:

$ xcode-select --install  $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"  $ brew doctor  $ brew update  $ brew install bash  $ sudo mv /bin/bash /bin/bash_old  $ sudo mv /bin/sh /bin/sh_old  $ sudo chmod a-x /bin/bash_old /bin/sh_old 

И теперь Bash больше не работает :( Когда я открываю терминал, он отображает это сообщение:

У вас есть новая почта.
login: / bin / bash: нет такого файла или каталога
[процесс завершен]

1
Загрузите установочный носитель и отмените внесенные изменения. Zoredache 8 лет назад 0
Если вы используете загрузчик [Grub] (http://www.gnu.org/software/grub/manual/), вы можете отредактировать командную строку ядра (с помощью клавиши 'e') и добавить `init = / bin / sh_old ` levif 8 лет назад 0
@Zoredache, как мне загрузить установочный носитель? verity1007 8 лет назад 0
Вы должны писать строки, похожие на `sudo ln -s /usr/local/Cellar/bash/4.3.25/bin/bash / bin / bash` (с правильной версией установленного` bash` и правильным путем), иначе вы никогда не найду его. Вы переместились и переименовали `bash` и` sh` с разными именами (`bash_old / sh_old`), которые вы пропустили, чтобы создать ссылки. Hastur 8 лет назад 1
@Hastur Я больше ничего не могу набрать в терминале, есть ли способ установить bash снова? verity1007 8 лет назад 0

1 ответ на вопрос

1
svenper

Terminal attempts to load /bin/bash (or whatever the default shell for the user is). Since you moved that, it doesn’t know what to do unless you tell it where to look instead. There are several ways to override the default login shell in OS X, that don’t require a current working shell.

For a specific user:

System Preferences → Users & Groups → right click user → Advanced Options… → Login shell

advanced user options

For the current user:

Terminal → Preferences… → General → Shells open with: → Command (complete path)

terminal default shell

For a specific Terminal profile:

Terminal → Preferences… → Profiles → ‹profile› → Shell → Run Command Also untick the “Run inside shell” box.

profile default shell

When you have a working shell, you can rename the binaries back to their originals and then use homebrew and use the same process to set /usr/local/bin/bash as the login shell. There is no need to replace binaries in /bin as the shell uses binaries from multiple directories using the PATH environment variable, including /usr/local/bin, which is the homebrew default install directory.