[Epic 4G Android Development] nubecoder:
android_bash

If you don't know what Bash is, search Google instead of asking that here. Thanks!

This is primarily useful to anyone who spends a fair amount of time either in adb or in a terminal.

To quote the README at github:

#

# android_bash

#

# 2011 nubecoder

# www.nubecoder.com/

#

Project info:

Bash, cross-compiled and modified for the android platform.

Modifications include:

Adjusted path of init files (.bashrc, .profile, etc) from '~/' to '/data/local/'.

Added support for storing init files on '/mnt/sdcard/' (only used when the files do not exist in '/data/local/').

Some default init files are included as (working) examples.

Stripped for size (args used for stripping: '-d --strip-unneeded').

Zips that can be installed via a custom recovery can be found here:

http://www.nubecoder.com/files/android/android_bash/​

Three versions of Bash, 3.2, 4.0, and 4.1 (I couldn't get 4.2 to build).

The recovery install-able zips linked above DO NOT replace the default shell.

To use after installed, log onto adb or a terminal emulator and type 'bash' or 'su -c bash' (for root) and hit enter.​

Now enjoy a real shell on your phone!

These files will be installed onto your phone:

Binary file:

/system/bin/bash​

Support files:

/system/etc/bash.bashrc

/system/etc/profile

/data/local/.bash_aliases

/data/local/.bashrc

/data/local/.inputrc

/data/local/.profile

Here's some more info on what these files are.

And here for .inputrc.​

After some testing, it seems the sdcard support needs to be fixed up a a bit.

.inputrc is not being looked for in '/mnt/sdcard' yet and '.bash_aliases' needs to be somewhere it can be "executable". Otherwise, it's contents should be moved into '.bashrc'

I'll fix up the '.inputrc' stuff and update with that later.

The sdcard support has been updated and is fully working for both .inputrc and .bash_aliases.

The support files include a decent set of configurations.

Here's a short list of some of them:

Colored prompt (red while root, green otherwise).

$HOME variable defined as '/data/local/' ('~/' now works).

Aliases for some busybox commands including adding '--color=auto' to 'ls' commands.

Allows use of CTRL+ARROW keys, correct DELETE functionality, etc.

$HISTFILE defined as '/mnt/sdcard/.bash_history'.​

Using Bash already and want to check which version it is? Run this in adb / terminal (requires busybox)

strings $(which bash) | grep "Bash version"​

or

echo $BASH_VERSION​

Taken from my post here.

Honestly, I have no Idea, the biggest difference I know of is file size (v3.2 being the smallest).

The three versions here are fully patched and up to date, so there's a chance that there is minimal difference between them.

I opted to offer the three versions, since it's pretty easy to build (when it doesn't give errors).

If anyone has a request for an older version (for whatever reason) I'd be happy to build that as well (assuming there aren't errors).​

Bash as default shell:

If you know what you are doing and want to use bash as the default shell.

Then I shouldn't have to tell you how to replace '/system/bin/sh' with a symlink to '/system/bin/bash'.

And that you should back up the original sh binary.

And that adb in recovery is the only way to fix your shell if you mess it up.

I didn't need to say those things, since you know what you are doing, right? =]

I should add here, that some kernels will "not allow" Bash as default shell, and by that I mean they have "/sbin/sh" and "/bin/sh" (symlinks to busybox) that will be created on every boot and are earlier in PATH than "/system/bin/" (ie will be used if found first).

DRockstar's Clean Kernel: /sbin/sh and PATH.

Rodderik's Genocide Kernel: /sbin/sh and PATH.​

This means that your new symlink for "/system/sh" will never be used.

It also means, you really can't break your shell like I described above (which is a good thing).

You can point you're favorite Kernel developer to my little fix that allows Bash to be used as the default shell.

What the fix does is:

Checks to see if "/system/bin/sh" is symlinked to "/system/bin/bash".

Checks that "/system/bin/bash" is a file that exists.

Removes "/bin/sh" and "/sbin/sh" and symlinks them to "/system/bin/sh".​

You could also put that little fix into an init.d script that has '/' mounted as RW.

(If I get around to doing this, maybe I'll add it to the packages.)​

These zips use generic mounting and should work on most devices that have a custom recovery.

There is a chance you may need to edit the PATH to get it properly working on your device. (See here for more info.)

The binaries can be used on any android (ARM) device.

Here's a link to the GitHub Project.

=]