Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,779,227 Members 47,097 Now Online
XDA Developers Android and Mobile Development Forum

[Shell][mksh][Scripting]::mksh-R50-static-FULL+mkshrc_mods:::

Tip us?
 
7175
Old
(Last edited by 7175; 5th August 2014 at 07:48 AM.)
#11  
7175's Avatar
Senior Member - OP
Thanks Meter 242
Posts: 210
Join Date: Feb 2013
@E:V:A : Glad the first execution you mentioned worked. I would try messing with quotes/double quotes around the shell command, i.e. ssh ... -T su -c 'exec ...' or try ssh ... -T su -c exec "...", as something to test out further. This can make a lot of difference.

The ulimit shell function can control all sorts of performance related stuff, priority, max niceness, etc. You can see all values with "ulimit -a".

I understand your hesitance about the libc.so replacement. I would keep a copy of the old one and twrp backup before trying out a new one. I get what you're saying about statically linked binaries. I just fixed my i7 desktop that had a blown power supply, so I'll be looking into this. Thanks for the linaro link!

@mirabilos : Thanks for taking a look at this and providing us with mksh! I updated my OP with the specifics about the rebinds for "control I" and "control U" that you mentioned, and I added a suffix to the beginning comments of the file. Something like:
Code:
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.88 2014/01/11 18:09:39 tg Exp $Android_mod by 7175@xda-developers.com 2014/08/04$
Not sure if that's what you wanted me to add in. I included an extra zip to download in the 2nd post that contains the official mkshrc 2014/01/11, my personal mkshrc, and a "diff -ur" patch (also attached to this post).

I will look into getting a statically linked mksh compiled, that sounds like something really handy to keep around.

edit: Here's basically what I added to the beginning and end of PS1 to trim down its "set -x" verbosity to 3 lines. I'd like to get it down more but haven't figured it out.
Code:
PS1=$'\001\r'; PS1+='${|
	local e=$?
	[[ -o -x ]] && set +x && global -x XTR_DBG=1 || global -x XTR_DBG=0
...
...
...
 (( XTR_DBG )) && set -x
	return ${e}
} '
|Device| = Galaxy Nexus "toro" |Batt's| =3800, 1850, 2100b (NFC-stripped) |Radio's| = FK-LTE/FA-cdma |Bootloader| = PRIMEMD04
|ROM's| = Vanir 4.3.1 ; Carbon 4.4 |RECOVERY| = TWRP |SU| = SuperSU!
|Kernels| = Vanir ; Dirty V, Fancy, Grakern --- FIOPS'd BFQ; Core:307; VAUX3:2500; COLOR:[Contrast=-2;Gamma=-4;+{-5, 0, 0}; x{180; 178; 200}]


Excellent GNEX[Ref][Guide] -- ART-compatible Apps -- [.SH][BIN] mksh/-rc FULL (R50 static) -- [BIN] busybox 1.23.0 -- [.SH][BIN] Easy SSH && TELNET
 
mirabilos
Old
(Last edited by mirabilos; 5th August 2014 at 09:17 AM.) Reason: more info
#12  
mirabilos's Avatar
Junior Member
Thanks Meter 6
Posts: 21
Join Date: Dec 2010

 
DONATE TO ME
Quote:
Originally Posted by 7175 View Post
@mirabilos : Thanks for taking a look at this and providing us with mksh!
You’re welcome!

Quote:
Originally Posted by 7175 View Post
Not sure if that's what you wanted me to add in.
Ah, so you did not patch the mksh binary, only the mkshrc file?
But then, that’s okay as you wrote, sure.

Quote:
Originally Posted by 7175 View Post
I included an extra zip to download in the 2nd post that contains the official mkshrc 2014/01/11, my personal mkshrc, and a "diff -ur" patch (also attached to this post).
OK, thanks. Will have a look at it within the next weeks (August is going to be a busy month for me).
I’m assuming you are okay with me adding some of your changes back to main mksh?

Quote:
Originally Posted by 7175 View Post
I will look into getting a statically linked mksh compiled, that sounds like something really handy to keep around.
Indeed, it is.

The first mksh run on Android actually was statically compiled against µClibc, though that’s cheating. (Also, dietlibc and klibc are better than µClibc). I think it should work against Bionic, too.

Quote:
Originally Posted by 7175 View Post
edit: Here's basically what I added to the beginning and end of PS1 to trim down its "set -x" verbosity to 3 lines. I'd like to get it down more but haven't figured it out.
I don’t think it works in less, considering you have to save the previous $?. There are a few handy tricks around. I tried these four:

#1 is:

Code:
	local e=$?
	[[ -o -x ]]; local x=$?; set +x

	(( e )) && REPLY+="$e|"
[…]
	(( x )) || set -x
	return $e
This is about what you did. #2 is:

Code:
	local e=$? x=$([[ -o -x ]]; echo $?); set +x

	(( e )) && REPLY+="$e|"
[…]
	(( x )) || set -x
	return $e
This only looks different (I’d prefer #1 over this.) #3 is:

Code:
	set +x $? $([[ -o -x ]]; echo $?)

	(( $1 )) && REPLY+="$1|"
[…]
	(( $2 )) || set -x
	return $1
This reduces visual clutter. #4 is:

Code:
	set +x $? $([[ -o -x ]]; echo $?)

	(( $1 )) && REPLY+="$1|"
[…]
	(( $2 )) && return $1
	(( $1 )) && set -x && return $1
	set -x
This reduces visual clutter even more, in that, when $? is 0, one line less is shown. But it makes the number of lines shown be not always the same. YMMV on whether to use this, #3 or #1.

This could be made even nicer *iff* mksh had the EXIT trap when leaving a function. The manpage says it’s TODO. This part of the manpage is from 1999 or older. (I started mksh in late 2002, early 2003.) Go figure… But now I have a reason to add it ☺

Another thing you could do is “set +o inherit-xtrace”, which makes functions not run with “set -x” when the main body runs with it. But wait, I see now that it does not affect ${|…;} blocks. This is a bug, which I’ll fix ☻
The Following User Says Thank You to mirabilos For This Useful Post: [ Click to Expand ]
 
E:V:A
Old
(Last edited by E:V:A; 7th August 2014 at 11:25 PM.)
#13  
E:V:A's Avatar
Recognized Developer
Thanks Meter 1761
Posts: 1,332
Join Date: Dec 2011
Location: -∇ϕ
@mirabilos:
Quote:
You Wrote:
Quote:
1. Would you have any clue to what's going on HERE?
You are annoying me. I've told you times and times again to disable SEAndroid, or to fix its SELinux policies.
Well, you can be as annoyed as you like. First of all, that question was not aimed at you, and second, as I have also said repeatedly, I have already tried using SELinux in Permissive mode and it doesn't work either. In addition, your suggestion to "fix its SELinux policies" is rather ridiculous as there are no tools available to do so. At least nothing out of the box and no available binaries anywhere, and surely no instructions how to do so. So if you know how to do it, why don't you just explain for us how to do so. (My policies are updated to latest according Androids policy update tools.)

In addition there is no such thing as "disable SEAndroid". It's either in Permissive or Enforced mode. That is, unless you flash a new custom FW, which is out of the question. In addition, ATE works just fine, in Enforcing mode.

So believe me, I am far more annoyed by Googles lack of SELinux/SEAndroid developer support, than you will ever be from me asking these questions.

Thanks for explaining and helping with everything else above.

@7175:
Quote:
The ulimit shell function can control all sorts of performance related stuff, priority, max niceness, etc. You can see all values with "ulimit -a".
Yes, I know about all those things, but I was asking why you think they need to be tweaked? The defaults, seem to work just fine.
MSM8960 Info, Architecture and Bootloader(s)
El Grande Partition Table Reference
How to talk to the Modem with AT commands

[REF][ServiceMode] How to make your Samsung perform dog tricks
[REF|R&D|RF] RF/Radio properties of Samsung ServiceMode

Want to know when your phone is getting tracked or tapped?

Help us develop the IMSI Catcher / Spy Detector!
(To be part of the EFF & The Guardian Project toolsets.)
_______________________________
If you like what I do, just click THANKS!
Everything I do is free, altruism is the way!
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
I do not answer support related PM's.

 
7175
Old
(Last edited by 7175; 24th August 2014 at 05:54 AM.)
#14  
7175's Avatar
Senior Member - OP
Thanks Meter 242
Posts: 210
Join Date: Feb 2013
@mirabilos : Thank you for your detailed replies, and I would be more than happy to contribute if you see anything from the content I posted.

It is interesting to see the other possibilities for turning off xtrace within the PS1. I didn't even realize you could set positional parameters after the set -x... I think I like that one the most. It just seems more array-like and streamlined, although I guess the same number of variables is still used. I look forward to seeing what updates you'll have on the exit trap and localization. This is something I'd like to toy around with.

I took your advice and set out to get a mksh static built. I ended up compiling with GCC, running "LDSTATIC=-static ./Build.sh" in the mksh source directory. I'm pretty new to cross compiling, so I didn't really get that far or try that hard before chrooting to a fresh Ubuntu terminal on my Nexus, installing GCC, and compiling there. The only thing I changed in the source code was ${ENV:-~/.mkshrc} to ${ENV:-/system/etc/mkshrc} in the "main.c" source file. I can include this in the OP though as you mentioned before. (edit: just saw this as a compiler option with Build.sh)

Edit: I see the option now in the Build.sh for changing the mkshrc path. Also, got R50 rebuilt static with klibc. Damn that got the size way down from using glibc, 684K to 204K.
|Device| = Galaxy Nexus "toro" |Batt's| =3800, 1850, 2100b (NFC-stripped) |Radio's| = FK-LTE/FA-cdma |Bootloader| = PRIMEMD04
|ROM's| = Vanir 4.3.1 ; Carbon 4.4 |RECOVERY| = TWRP |SU| = SuperSU!
|Kernels| = Vanir ; Dirty V, Fancy, Grakern --- FIOPS'd BFQ; Core:307; VAUX3:2500; COLOR:[Contrast=-2;Gamma=-4;+{-5, 0, 0}; x{180; 178; 200}]


Excellent GNEX[Ref][Guide] -- ART-compatible Apps -- [.SH][BIN] mksh/-rc FULL (R50 static) -- [BIN] busybox 1.23.0 -- [.SH][BIN] Easy SSH && TELNET
Tags
busybox, grep, ksh, mksh, shell
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes