• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

shell bash for android

Search This thread

shafty023

Senior Member
Jul 24, 2007
1,131
98
Austin,TX
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.
 

mzet

Senior Member
Mar 23, 2008
67
11
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...
 
  • Like
Reactions: digigamer

overground

Retired Senior Moderator / Inactive Recognized Dev
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!
 
Last edited:

ttabbal

Senior Member
Jul 1, 2009
2,076
723
Samsung Galaxy S21 Ultra
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. :)
 
Last edited:

lbcoder

Senior Member
Jan 21, 2009
2,622
99
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/showpost.php?p=3839562&postcount=4 to see if what you want is already done.

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
 

shafty023

Senior Member
Jul 24, 2007
1,131
98
Austin,TX
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/showpost.php?p=3839562&postcount=4 to see if what you want is already done.

In that version of bash from the link you provided, the dev had an issue with the <enter> key working. This issue does not exist in this version. There's nothing wrong with someone compiling and providing their own version of something. This is exactly the same reason ROM developers on here create their own (and for the most part identical) ROMs as the next guy. We shouldn't hamper innovation, we should support it. Progress is measured by how well someone can build off another's innovation.

Plane->Jet->Space Shuttle. Imagine if we told the guy who invented the jet, hey retard, someone already made an F16, take your stealth bomber and shove it :p
 
  • Like
Reactions: RudeBwoy

dipeshb

Senior Member
Feb 13, 2006
208
9
in that version of bash from the link you provided, the dev had an issue with the <enter> key working. This issue does not exist in this version. There's nothing wrong with someone compiling and providing their own version of something. This is exactly the same reason rom developers on here create their own (and for the most part identical) roms as the next guy. We shouldn't hamper innovation, we should support it. Progress is measured by how well someone can build off another's innovation.

Plane->jet->space shuttle. Imagine if we told the guy who invented the jet, hey retard, someone already made an f16, take your stealth bomber and shove it :p


well said shafty!!
 

lbcoder

Senior Member
Jan 21, 2009
2,622
99
That had nothing to do with the bash, it had to do with "better terminal emulator".

And your analogies are wrong since the end result is the SAME THING.
If you want to contribute to things, invent something NEW. Don't keep on reinventing the wheel, we already know that its round.

In that version of bash from the link you provided, the dev had an issue with the <enter> key working. This issue does not exist in this version. There's nothing wrong with someone compiling and providing their own version of something. This is exactly the same reason ROM developers on here create their own (and for the most part identical) ROMs as the next guy. We shouldn't hamper innovation, we should support it. Progress is measured by how well someone can build off another's innovation.

Plane->Jet->Space Shuttle. Imagine if we told the guy who invented the jet, hey retard, someone already made an F16, take your stealth bomber and shove it :p
 
Last edited:

inoah

Member
Jul 14, 2009
32
0
Seattle, WA
www.splode.com
Last edited:

shafty023

Senior Member
Jul 24, 2007
1,131
98
Austin,TX
That had nothing to do with the bash, it had to do with "better terminal emulator".

And your analogies are wrong since the end result is the SAME THING.
If you want to contribute to things, invent something NEW. Don't keep on reinventing the wheel, we already know that its round.

Being a senior member you should know better than to put people down. Let's not go down this road, there's plenty of development to do and no time to do it.
 

dumfuq

Retired Recognized Developer
May 23, 2009
542
42
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. :)

It won't work as default shell but if you use better terminal just make it the initial command and it can be on sd. Also it makes it persistent even through wipes.

in better terminal:
Code:
su -c "/system/sd/bin/bash --rcfile /system/sd/bashrc"

then in /system/sd/bashrc:
Code:
export PATH=${PATH}:/system/sd/bin

if [[ $- != *i* ]] ; then
	# Shell is non-interactive.  Be done now!
	return
fi

if [[ ${EUID} == 0 ]] ; then
	PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
	PS1='\[\033[01;32m\]\[email protected]\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi
 

Top Liked Posts

  • There are no posts matching your filters.
  • 9
    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
    2
    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.
    1
    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...
    1
    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/showpost.php?p=3839562&postcount=4 to see if what you want is already done.

    In that version of bash from the link you provided, the dev had an issue with the <enter> key working. This issue does not exist in this version. There's nothing wrong with someone compiling and providing their own version of something. This is exactly the same reason ROM developers on here create their own (and for the most part identical) ROMs as the next guy. We shouldn't hamper innovation, we should support it. Progress is measured by how well someone can build off another's innovation.

    Plane->Jet->Space Shuttle. Imagine if we told the guy who invented the jet, hey retard, someone already made an F16, take your stealth bomber and shove it :p
    1
    51dusty; person is probably not using Notepad++ or Linux.

    If you don't use a text editor that delineates line-breaks in a POSIX/UNIX friendly way, Linux machines will then read everything as being a /single/ line. However, you can use the ";" as a 'line break' of sorts within the same line. You can also do the same thing using an actual 'carriage return character' at the end of your lines -- but that's messy.