FORUMS
Remove All Ads from XDA

shell bash for android

66 posts
Thanks Meter: 10
 
By mzet, Member on 17th July 2009, 10:13 PM
Post Reply Email Thread
hi,
i compiled bash and added support for executing file /sdcard/bash_profile, so you can set PATH and PS1 variables there, for example...

if someone is interested, there it is for download
http://pub.mzet.net/bash

for become default shell copy bash to /system/bin/bash a then run:
Code:
cd /system/bin
chmod 0755 bash
mv sh sh0
ln -s bash sh
The Following 8 Users Say Thank You to mzet For This Useful Post: [ View ] Gift mzet Ad-Free
 
 
17th July 2009, 10:21 PM |#2  
Senior Member
Flag Austin,TX
Thanks Meter: 98
 
More
Quote:
Originally Posted by mzet

hi,
i compiled bash and added support for executing file /sdcard/bash_profile, so you can set PATH and PS1 variables there, for example...

if someone is interested, there it is for download
http://pub.mzet.net/bash

for become default shell copy bash to /system/bin/bash a then run:

Code:
cd /system/bin
chmod 0755 bash
mv sh sh0
ln -s bash sh

NICE! Good job mzet. I missed bash and its wonderful auto complete. This should help spur better scripting with all the functionality that bash supports. No more semicolons at the end of each line in a shell script.
The Following 2 Users Say Thank You to shafty023 For This Useful Post: [ View ] Gift shafty023 Ad-Free
17th July 2009, 10:23 PM |#3  
Senior Member
Flag Austin,TX
Thanks Meter: 98
 
More
On a side note, we should be able to add the following to init.rc rather than symlinking sh -> bash

export SHELL /system/bin/bash
17th July 2009, 10:28 PM |#4  
OP Member
Thanks Meter: 10
 
More
here is example of my /sdcard/bash_profile
Code:
PATH=/sbin:/system/xbin/bb:/system/xbin:/system/bin
if [[ ${EUID} == 0 ]] ; then
  PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
  PS1='\[\033[01;32m\]\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi
it shows localhost in green color when user is logged or in red color when root is logged...
The Following User Says Thank You to mzet For This Useful Post: [ View ] Gift mzet Ad-Free
17th July 2009, 10:30 PM |#5  
OP Member
Thanks Meter: 10
 
More
Quote:
Originally Posted by shafty023

On a side note, we should be able to add the following to init.rc rather than symlinking sh -> bash

export SHELL /system/bin/bash

strange. is this variable used? when i execute "echo $SHELL" it writes "/bin/sh", but it does not exists, it should write /system/bin/sh, i think
17th July 2009, 10:42 PM |#6  
DeToX-cz's Avatar
Senior Member
Flag Breclav
Thanks Meter: 21
 
More
"/bin/sh" is ok. It's in boot.img...(respectively in ramdisk). Check out some ramdisk
17th July 2009, 10:43 PM |#7  
Senior Member
Flag Austin,TX
Thanks Meter: 98
 
More
Quote:
Originally Posted by mzet

strange. is this variable used? when i execute "echo $SHELL" it writes "/bin/sh", but it does not exists, it should write /system/bin/sh, i think

Ya I noticed that after posting my last message. Perhaps it's not used. I'll try and find some time to change that in init.rc and reboot to see if it takes effect
17th July 2009, 10:55 PM |#8  
overground's Avatar
Moderator & Developer Committee Member / Senior Moderator / Inactive Recognized Developer
Flag Oxnard, CA Likes: Los Angeles Lakers Dislikes: Heavy petting zoos
Thanks Meter: 2,223
 
Donate to Me
More
Quote:
Originally Posted by shafty023

Ya I noticed that after posting my last message. Perhaps it's not used. I'll try and find some time to change that in init.rc and reboot to see if it takes effect

I tried adding that to my init.rc and not doing the symlink and lost my shell, which I expected. I figured a reboot would fix it, but got stuck @ boot image. No problem...recent nandroid.

EDIT: Using the symlink works fine for now. Thank you!
17th July 2009, 11:27 PM |#9  
Senior Member
Thanks Meter: 706
 
More
Very cool. Thanks for giving us bash for Andriod! While we're thinking of low level tools, anyone have a version of busybox with colorized 'ls'?

Anyone know when /system/sd is mounted in the cyano ROMs? If it's available early enough, we could copy bash to /system/sd and avoid taking up 2.5MB in /system/bin.
18th July 2009, 12:50 AM |#10  
OP Member
Thanks Meter: 10
 
More
it's too big, because everything is built statically
20th July 2009, 04:12 PM |#11  
Account currently disabled
Thanks Meter: 99
 
More
You know, before going off and compiling things (wasting your time), it is not too bad an idea to do a search... http://forum.xda-developers.com/show...62&postcount=4 to see if what you want is already done.

Quote:
Originally Posted by mzet

hi,
i compiled bash and added support for executing file /sdcard/bash_profile, so you can set PATH and PS1 variables there, for example...

if someone is interested, there it is for download
http://pub.mzet.net/bash

for become default shell copy bash to /system/bin/bash a then run:

Code:
cd /system/bin
chmod 0755 bash
mv sh sh0
ln -s bash sh

Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes