Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

When I adb into a device with Cyanogenmod, I'm presented with a nice bash shell, color prompt, and bashrc. I don't see a symlink from /system/xbin/bash to /system/bin/sh. How do they set the default shell to bash instead of sh? I looked through rc files, but didn't find anything. I'd like to do the same on my Android build, which isn't Cyanogenmod.

Update

After re-installing from scratch with CM7, I'm taken to sh instead of bash. Now the question is how to set bash as default.

share|improve this question
    
Vanilla CM7 (built from source) drops me at sh, not bash, when I use adb to connect. What build are you using? –  eldarerathis Feb 10 '12 at 2:00
    
It's 7.1.0.1 for the ViewSonic G Tablet. I didn't build from sources though. –  Ravi Feb 10 '12 at 2:37
add comment

2 Answers

I didn't have my Android with me right now to test, but with the Android Terminal Emulator if you go to the menu, you might be able to use the "Command line" or "Initial command" option.

enter image description here

share|improve this answer
add comment

When adb shell is executed, the Android side also launches adb which then executes /system/bin/sh -. This path is hard-coded in system/core/adb/services.c:

347 #if ADB_HOST
348 #define SHELL_COMMAND "/bin/sh"
349 #define ALTERNATE_SHELL_COMMAND ""
350 #else
351 #define SHELL_COMMAND "/system/bin/sh"
352 #define ALTERNATE_SHELL_COMMAND "/sbin/sh"
353 #endif

If you want to change this to bash, you will have to recompile it.

It is possible to execute some commands from file when running the interactive shell. As written in system/core/sh/main.c, sh - (note the - for interactive mode) reads from the following files (in this order):

  • /etc/profile
  • .profile (relative to current directory, this is /.profile for adb shell
  • $ENV (environment variable ENV should point to a file)

As /etc/ and / are read-only, the only way to get something loaded was by setting ENV. You can probably create a symlink from /etc/profile to /data/profile by mounting / read-write (exercise for the reader).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.