yashsingh1/xdaforums huggingface dataset:
[Asus Transformer TF700] sbdags:
I'll test it on mine now mate ;)

---------- Post added at 10:45 PM ---------- Previous post was at 10:19 PM ----------

Well it does something as I lost all my icons on my widgets and had to refresh to get the cache to rebuild again. On CROMi-X it doesn't appear to make much difference though. Certainly not noticeable. I'll leave it on for a day to see if it helps and any negative effects. I assume all cache will be lost she a reboot occurs?
[Asus Transformer TF700] Tylorw1:
I thought the same thing about speeding other things up. So, I set up the Play Store cache, because I figured the tablet having to cache all the images, it would reduce the lag when surfing through Play Store, but it didnt work really. Put it in the script, noticed no difference in play store.

Tylor

ROM: CromiX 4.5 DeOdex

Kernel: MaxKernel V2
[Asus Transformer TF700] shardsx:
I think performance gains would only be noticed on apps that extensively writes to the /cache folder, such as web browsers. I don't know how much benefit there is to gain from mounting any other /cache folder to tmpfs.

At any rate, I have taken the script one additional step further and modified it so that at boot time, it searches /data/data for any applications and its associated /cache directory (if it exists) and mounts it to tmpfs.

In my current testing, it causes the YouTube app to FC at boot (I don't know what causes this, but the app runs fine afterwards), so I made a modification to the script to exclude YouTube specifically.

It doesn't seem to speed anything else up, but I thought rather than specifically adding individual browsers to the script, I'd go with the shotgun approach and automatically mount as many apps to tmpfs as possible.

If there's interesting in the script, I will post it.

So far, I haven't noticed any abnormal behavior other than YouTube FCing on bootup, which I've resolved by excluding its /cache directory from being mounted to tmpfs.

I'm running CROMI 3.4.6 on a TF300T.
[Asus Transformer TF700] sbdags:
Yeah I'm pretty sure the launcher and systemui caching does very little. The file sizes are tiny. You are talking bytes and kilobytes for the cache sizes not megabytes. Certainly no noticeable difference and maybe placebo but I think scrolling lists is slower now.
[Asus Transformer TF700] elfaure:
Guys, thanks for checking it out. I had no problems with icons or widgets on stock ROM. The only wierdness I observed was when I launched Music there was some cyclic loading glitch in loading the album cover art but that was about it. I have a decent size 5 GB music library so maybe my art data exceeded my cache size? Yes the cache data will be gone after a reboot as is the nature of volatile memory (RAM).

What I observe is initially there is no boost. But after having say 10 apps loaded, switching between them (screens) and reloading each after switching between them *seems* faster.

[Edit] But when I loaded the actual *app* and cache into RAM, then I did loose all my icons and widgets. A reboot brought back the icons but not the widgets.
[Asus Transformer TF700] elfaure:
Thanks for testing and your feedback. Your first paragraph statement is exactly what [MENTION=4878287]_that[/MENTION] said and also seemed obvious to me but you never know so I thought I'd test it.

Shotgun approach - I bet you have nearly as many mounts as you have applications since most apps have a /cache directory?

Please post the code (if you want to share) for searching /data/data for */cache and then mounting */cache to tmpfs. Did you use the same structure as currently in the script "if [ -d /data/data... ]"?
[Asus Transformer TF700] shardsx:
Yes, you're absolutely right; I do have as many mount points as I do applications. Every single app with a /cache directory(minus the ones that I explicitely filtered out from the script) has a mount point. I don't know if having so many mount points harms performance in any way, but I've only made the script less than 24hrs ago and thorough testing and more time are required to confirm this. Just as an FYI, I have 104 apps installed.

I'm attaching the code to this post below.

I didn't use the "if [ -d /data.... ] structure but went for a for-loop instead. I'm not a bash shell specialist by any stretch of imagination (though I learned a lot from this exercise), so I'm sure someone with more shell experience can optimize the code.

I also used a different set of switches for the "rm" command than your original script. I don't know why, but -rf did not work for me. The 'f' switch just kept causing errors and wouldn't do anything. Otherwise, it's pretty much a modification of your original code. Thank you so much for the inspiration!
[Asus Transformer TF700] elfaure:
Thanks for the attachment and feedback. Glad I could be an inspiration. XDA is an inspiration. Expert scripter I am not. In fact, this is my first script but I have also learned a ton.

Note: Actually its not bash its sh shell scripting otherwise the first line would be:

#!/system/bin/bash
[Asus Transformer TF700] shardsx:
Oops! Haha, good catch. See; definitely not a scripting specialist! :D All the stuff I googled were for bash, but yes, it's a sh script. LOL.
[Asus Transformer TF700] FrostByghte:
Thank you much for this idea...might have to play around with some additional caching as well! w00t! :)
[Asus Transformer TF700] Tylorw1:
If anyone wants to download the script I been working on, here it is: http://d-h.st/svP

It supports:

1. Stock

2. Boat Browser

3. Chrome

4. Naked

5. Maxthon

6. Firefox

7. Opera

8. UC Browser HD for Tablet

9. Dolphin Browser

10. NineSky Browser

11. Floating Browser

If you have another browser you want added, let me know.

Enjoy!

Tylor

ROM: CromiX 4.5 DeOdex

Kernel: MaxKernel V2
[Asus Transformer TF700] CiaronDarcOne:
Does this just get flashed mate?
[Asus Transformer TF700] Tylorw1:
No this is just the script. You use Root Browser copy it and paste the file into /system/etc/init.d/ and restart the tablet. I can put it in a flashable zip however. I currently added Chrome Beta to B2R as well. I am think of starting a thread soon about it that way I can keep it updated.

Tylor

ROM: CromiX 4.5 DeOdex

Kernel: MaxKernel V2
[Asus Transformer TF700] CiaronDarcOne:
Awesome, feels better already. Thanks again. Any need to keep the old script or should I bin it? Do they conflict?
[Asus Transformer TF700] Tylorw1:
You can get rid of the old one but I dont think it matters. Which browser you using it on atm? Boat?

Tylor

ROM: CromiX 4.5 DeOdex

Kernel: MaxKernel V2
[Asus Transformer TF700] CiaronDarcOne:
Yes boat. There were quite a lot of occasions I would get 'not responding' messages before. Thought it might have been i/o issues. I reckon this might fix it, I'll keep you posted. Already I've noticed image heavy sites are loading so much faster and without stutter.
[Asus Transformer TF700] Tylorw1:
So it is true that Boat dont use the stock cache, neither does dolphin, so both browser should now be much speedier. B2R isnt gonna make it run perfect, but it will make it run much better. The Not Responding happens from the i/o trying to write and freezing the app. Terrible that this device has such terrible i/o. But we can only tweak it now :).

Tylor

ROM: CromiX 4.5 DeOdex

Kernel: MaxKernel V2
[Asus Transformer TF700] elfaure:
[MENTION=5234163]shardsx[/MENTION]

Can you run me thru these two lines of your code and what they do? It appears you are redefining the variable CACHE_NAME between these two lines and piping the first into the second?

CACHE_NAME=${CACHE_FULL_PATH/'/data/data/'/''}
CACHE_NAME=${CACHE_NAME/'/'/'_'}
[Asus Transformer TF700] elfaure:
Note: You can only use the init.d method on non-stock ROM, or if you did [MENTION=4878287]_that[/MENTION] 's install-recovery.sh trick. On stock ROM you have to use Script Manager to load it at boot and run it as root.
[Asus Transformer TF700] elfaure:
Whatever differences there are between them, I'm sure they are minor as related to basic scripting and bash shell code is identical in most cases.
[Asus Transformer TF700] shardsx:
For sure!

At the beginning of my script, I call "find" in /data/data for anything that contains a /cache directory. Basically, looking for the string "/data/data/*/cache" and storing the resulting string in CACHE_FULL_PATH.

Next comes the two lines you're asking about. I needed a variable to store just the application name, so that I could make a "<app_name>_cache" string and store it in CACHE_NAME. For example, if we look at the flipboard app, the value for this stored in CACHE_FULL_PATH is "/data/data/flipboard.app/cache". I needed to find a way to get rid of the "/data/data/" and "/cache", but I couldn't figure out how to do it using only one line of code (this is the part where I admit someone with more experience can optimize the code).

So, for the two lines of code you're asking about, the first line removes the "/data/data/" portion and stores the resulting string in CACHE_NAME. The second line takes the value of CACHE_NAME and removes the "/cache" portion and stores it back inside CACHE_NAME.

Edit: Wait wait wait... it's 1:40am. I can't think straight. Sorry. The second line replaces the only "/" left in CACHE_NAME with a "_" character. Basically, here's what happens with the variables (using Flipboard again as an example)

For loop executes, finds Flipboard: CACHE_FULL_PATH=/data/data/flipboard.app/cache

First CACHE_NAME line executes: CACHE_NAME=flipboard.app/cache

Second CACHE_NAME line executes: CACHE_NAME=flipboard.app_cache
[Asus Transformer TF700] dgjl:
Definitely improves stock experience, but doesn't seem to do anything to Dolphin. Anybody get any improvement who's using Dolphin? (I'm on CM10.1)
[Asus Transformer TF700] elfaure:
Thanks for the explanation! Now its clear what's going on there. Interesting "shotgun" approach and nice work, but I'm not sure I would want all those mounts especially if they don't do anything beneficial. Then again, if there's no performance lost by having all those mounts it is a universal generic approach that is not app list specific so it works for any and all browsers (and all apps) the user has installed without even knowing which they are which is quite attractive. Like you weeded out youtube, maybe you could make a list of say 30 known browser names and then weed all out that don't match that list. Then the code could remain universal and only the browser list becomes specific. Users could define and manage their own list within the script to match against.

Where two lines of code gets the job done and one line requires expert skills and 10 years experience I would fall back to the former. But if you did want a single line to do this you would want to use the "sed" command. Grep, awk, and sed are very powerful commands if you know how to use them which I do not. But you might be able to pick up a few tricks by reviewing [MENTION=2446267]becomingx[/MENTION] 's code here:

http://xdaforums.com/showthread.php?t=2264643
[Asus Transformer TF700] _that:
A small shell scripting exercise

Want to know that 10 biggest cache using apps? One short line in a root shell. :)

du /data/data/*/cache | sort -rn | head

"du" calculates disk usage.

/data/data/*/cache is expanded by the shell to list the cache directories for all apps.

The output of "du" is a list of used space (in kilobytes) followed by the directory name.

We pipe this into "sort". You can find out about its options with "sort --help".

Finally, I pipe the sorted result to "head". Use "head --help" to find out what it does.
[Asus Transformer TF700] elfaure:
Can someone tell me why this code executes fine from the terminal but won't in a script?

PATH=${PATH}:/Removable/MicroSD/Scripts

***************************************

Here's my output (just rebooted):

u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # du /data/data/*/cache | sort -rn | head
8976 /data/data/com.adrenalinebrowser.browser/cache
8864 /data/data/com.adrenalinebrowser.browser/cache/webviewCacheChromium
4548 /data/data/com.android.providers.downloads/cache
4204 /data/data/com.baidu.browser.inter/cache
4172 /data/data/com.baidu.browser.inter/cache/webviewCacheChromium
3244 /data/data/com.tencent.ibibo.mtt/cache
3224 /data/data/com.tencent.ibibo.mtt/cache/webviewCache
2748 /data/data/com.android.chrome/cache
2728 /data/data/com.android.chrome/cache/Cache
1620 /data/data/com.mx.browser/cache
u0_a87@android:/ #

For duplicates I assume you would want to mount at the parent directory?
[Asus Transformer TF700] sbdags:
Very interesting! Browser is only using 592KB of cache .......

I'll have to use it more and see how it grows.

Most other processes are using 20 to 50KB. ;)
[Asus Transformer TF700] _that:
What does it do in the script, and what did you expect it to do?
[Asus Transformer TF700] becomingx:
How does it not work? Error message, can't call scripts from `/Removable/MicroSD/Scripts', something else?

Try adding the `-s' flag to the `du' command, should clean up the output a bit :)
[Asus Transformer TF700] elfaure:
It does nothing in a script. I expected it would do the same thing it does from the terminal with is append /Removable/MicroSD/Scripts to my $PATH.

u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # echo $PATH
/system/bin:/system/xbin
u0_a87@android:/ # cd /Removable/MicroSD/Scripts
u0_a87@android:/Removable/MicroSD/Scripts # cat scripts_to_PATH.sh
#!/system/bin/sh
PATH=${PATH}:/Removable/MicroSD/Scripts

u0_a87@android:/Removable/MicroSD/Scripts # sh ./scripts_to_PATH.sh
u0_a87@android:/Removable/MicroSD/Scripts # echo $PATH
/system/bin:/system/xbin
u0_a87@android:/Removable/MicroSD/Scripts # PATH=${PATH}:/Removable/MicroSD/Scripts
u0_a87@android:/Removable/MicroSD/Scripts # echo $PATH
/system/bin:/system/xbin:/Removable/MicroSD/Scripts
u0_a87@android:/Removable/MicroSD/Scripts #
[Asus Transformer TF700] elfaure:
See my last post for item 1. For item 2, yes the "-s" option looks better

u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # du -s /data/data/*/cache | sort -rn | head
44896 /data/data/com.android.providers.downloads/cache
8976 /data/data/com.adrenalinebrowser.browser/cache
8060 /data/data/com.android.chrome/cache
4204 /data/data/com.baidu.browser.inter/cache
3244 /data/data/com.tencent.ibibo.mtt/cache
1620 /data/data/com.mx.browser/cache
1608 /data/data/com.dolphin.browser/cache
1444 /data/data/com.android.vending/cache
956 /data/data/com.gogii.textplus/cache
584 /data/data/com.android.email/cache
u0_a87@android:/ #
[Asus Transformer TF700] becomingx:
Prefix the line with the keyword `export' -- should do the trick.
[Asus Transformer TF700] _that:
It does work, but only inside the script (which runs in a child shell, not in your current one). To make it modify your current shell, either do this:

or call the script using "source", which is usually abbreviated as ".", e.g.

. ./scripts_to_PATH.sh
[Asus Transformer TF700] elfaure:
Didn't work. You are officially demoted one level below GOD now. I'm keeping a tally on all you guys.

u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # cd /Removable/MicroSD/Scripts
u0_a87@android:/Removable/MicroSD/Scripts # echo $PATH
/system/bin:/system/xbin
u0_a87@android:/Removable/MicroSD/Scripts # cat scripts_to_PATH.sh
#!/system/bin/sh
export PATH=${PATH}:/Removable/MicroSD/Scripts
u0_a87@android:/Removable/MicroSD/Scripts # sh ./scripts_to_PATH.sh
u0_a87@android:/Removable/MicroSD/Scripts # echo $PATH
/system/bin:/system/xbin
u0_a87@android:/Removable/MicroSD/Scripts #
[Asus Transformer TF700] elfaure:
My goal is a single script to append this to my path. I want to do this at boot.

???

u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # cd /Removable/MicroSD/Scripts
u0_a87@android:/Removable/MicroSD/Scripts # cat call_scripts_to_PATH.sh
. ./Removable/MicroSD/Scripts/scripts_to_PATH.sh
u0_a87@android:/Removable/MicroSD/Scripts # sh ./call_scripts_to_PATH.sh
./call_scripts_to_PATH.sh[1]: .: ./Removable/MicroSD/Scripts/scripts_to_PATH.sh: No such file or directory
1|u0_a87@android:/Removable/MicroSD/Scripts #
[Asus Transformer TF700] becomingx:
Hehe. I think I got confused for a sec because it does work inside of shell init scripts. Try _that's method, it seems to work in my quick testing.
[Asus Transformer TF700] _that:
I said, "call the script using .", not "modify the script". :)

root@android:/data # cat > test.sh
#!/bin/sh
foo=bar
root@android:/data # . ./test.sh
root@android:/data # echo $foo
bar

But this won't help you if you want to run it at boot. To modify your PATH permanently, the easiest way is probably to edit /system/etc/mkshrc.
[Asus Transformer TF700] elfaure:
What happened here? Guess sh can't call sh!

u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # cd /Removable/MicroSD/Scripts
u0_a87@android:/Removable/MicroSD/Scripts # cat ./call_scripts_to_PATH.sh
. sh ./Removable/MicroSD/Scripts/scripts_to_PATH.sh
u0_a87@android:/Removable/MicroSD/Scripts # sh ./call_scripts_to_PATH.sh
./call_scripts_to_PATH.sh: /system/bin/sh[2]: syntax error: '@"4R4(444444}C}CDTT
RtdDTTx qYhLh\h\Qtdp(
x
Y#*19AIPZdnx!',4;AIV]mu|%█│▒7│▒C ▒␊▒␉␋ ┤┼┬␋┼␍ ␌⎻⎻ ⎻⎼█°⎼␊␊└␊└⎽␊├ ▒␊▒␉␋ ┤┼┬␋┼␍ ␌⎻⎻ ⎻⎼1 ␊⎼⎼┼⎺⎽␋±⎻⎼⎺␌└▒⎽┐±␊├⎻␋␍⎽├⎼┌␊┼⎺⎻␊┼┬⎼␋├␊␌┌⎺⎽␊ ⎽├▒␌┐ ␌#┐ °▒␋┌ ⎽├▒␌┐ ␌#┐ ±┤▒⎼␍⎼␊▒␍⎽├⎼┌␌⎻≤ ▒␊▒␉␋ ┤␋␍␋┴└␊└␌⎻≤ ▒␊▒␉␋ ┤␋␍␋┴└⎺␍⎽├⎼⎽├⎼─⎽⎺⎼├└▒┌┌⎺␌⎼␊▒┌┌⎺␌ ┌␋␉␌ ␋┼␋├␊│␋├ ␍⎽⎺ #▒┼␍┌␊ INIT ARRAY FINI ARRAY ␊│␊␌┴␊±␊├┤␋␍±␊├±␋␍±␊├␊┤␋␍±␊├␊±␋␍±␊├⎻⎻␋␍⎽␊├⎽␋␍⎽␊├⎼␊⎽±␋␍⎽␊├⎼┌␋└␋├±␊├⎼┌␋└␋├±␊├⎼┤⎽▒±␊⎽␊├±⎼⎺┤⎻⎽⎽␊├⎻±␋␍┌⎽␊␊┐⎻␋⎻␊␍┤⎻2┤┼┌␋┼┐␌#␍␋⎼␌#└⎺␍␌#⎺┬┼°⎽├▒├⎽├▒├┌⎽├▒├⎼␊▒␍┌␋┼┐⎼␊┼▒└␊▒␌␌␊⎽⎽±␊├├␋└␊⎺°␍▒≤⎽␋±▒␌├␋⎺┼┤└▒⎽┐┐␋┌┌⎽␋±⎽␊├┘└⎻⎽␋±┌⎺┼±┘└⎻⎽├⎼␌└⎻└␊└└⎺┴␊▒┌▒⎼└°⎺⎼┐␊┼┴␋⎼⎺┼⎽├⎼␌#⎼°␌┼├┌⎽├⎼┼␌└⎻ ▒␊▒␉␋ ␋␍␋┴±␊├␌┬␍ ▒␊▒␉␋ ␋␍␋┴└⎺␍±␊├⎻±⎼⎻␋⎽▒├├≤␋⎺␌├┌┐␋┌┌⎻±┼␋␌␊└␊└␌#⎼⎺⎻␊┼␍␋⎼⎼␊▒␍␍␋⎼␌┌⎺⎽␊␍␋⎼┬▒␋├⎻␋␍⎽␊├⎼␊⎽┤␋␍⎽≤⎽ ⎽␋±┌␋⎽├⎽≤⎽ ⎽␋±┼▒└␊⎽␋±⎽┤⎽⎻␊┼␍⎽┌␊␊⎻⎽├⎼␊⎼⎼⎺⎼├␌±␊├⎻±⎼⎻├␌⎽␊├⎻±⎼⎻└┐⎽├␊└⎻⎽├⎼┼␌▒⎽␊␌└⎻⎽├⎼␌▒⎽␊␌└⎻⎽├⎼␌▒⎽␊⎽├⎼ ␊␍▒├▒ ␉⎽⎽ ⎽├▒⎼├ ␊┼␍┌␋␉␌▼⎽⎺C$(Y=N!KB]IP<TFX3QU◀ \>
*[1;▲(MH2@^R'8ELOG6:
%C?&JD)4 Z $█▶/▼#A5
V79SW)"d"h"l"p"TTTTTTTTTTTTTTTTTTTTUU
UUUU$U' unexpected
1|u0_a87@android:/Removable/MicroSD/Scripts # 1;2c
[Asus Transformer TF700] elfaure:
Actually I didn't modify the script. I wrote a new script to call the original script with your syntax.
[Asus Transformer TF700] _that:
You can call sh from a shell script. But you shouldn't try to "source" sh. :)
[Asus Transformer TF700] elfaure:
Ok so I edited the mkshrc file and added the line below just above the line that says

": place customisations above this line" (yes, customizations is misspelled as is much of Asus' comments) and now I have two entries for that path. Why is _that?

Code I added:

PATH=${PATH}:/Removable/MicroSD/Scripts

Where Added:

...

for p in ~/.bin; do
[[ -d $p/. ]] || continue
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
done

unset p

PATH=${PATH}:/Removable/MicroSD/Scripts
...

[Edit] It works perfectly replacing the above PATH call with this one, then there is only one appended to $PATH

PATH=$PATH:/Removable/MicroSD/Scripts

Terminal Output:

u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # echo $PATH
/system/bin:/system/xbin:/Removable/MicroSD/Scripts:/Removable/MicroSD/Scripts
u0_a87@android:/ #
[Asus Transformer TF700] elfaure:
Hey man you still throw down the meanest sed I've ever seen. We won't ding you too hard for batting 99.98% I'm forever mortal so expect me to error frequently.
[Asus Transformer TF700] ronniereiff:
dolphin browser no longer stops responding while loading pages :laugh:
[Asus Transformer TF700] _that:
This one is from upstream (Google or even MirOS), and it's not even wrong.

Apparently mkshrc is executed when starting the shell, and again when you "su".

And this snippet seems to be the cure for that:

...

for p in ~/.bin; do
[[ -d $p/. ]] || continue
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
done

Replace ~/.bin with your desired path or add it after a space before ";" - the code in the loop seems to do the following:

[[ -d $p/. ]] || continue

If it's not an existing directory, ignore it.

[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH

If the path doesn't already contain the directory, add it.
[Asus Transformer TF700] elfaure:
I got it. Its easier than _that. Sticking with your original method of editing the file, and exactly where I put it, it works perfectly replacing the cited PATH call with this one, then there is only one appended to $PATH. (I removed the {} around PATH)

PATH=$PATH:/Removable/MicroSD/Scripts
[Asus Transformer TF700] _that:
And after "su"?
[Asus Transformer TF700] elfaure:
In my mkshrc file edit. No "su" there.

...

for p in ~/.bin; do
[[ -d $p/. ]] || continue
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
done

unset p

PATH=$PATH:/Removable/MicroSD/Scripts
...

Hey thanks to ALL you guys for helping me bang this out and get it to work in under an hour. Now when script testing from the terminal I can simply type the script name without its long path or having to cd long path and _that's a joy.

And this can be used as a general method to permanently add to your $PATH; just add a space between paths and append some more paths to the last line above. Appreciate it (thanks again)! :)
[Asus Transformer TF700] dgjl:
I very rarely had that problem - it's just not any quicker, unlike stock.
[Asus Transformer TF700] _that:
I meant it will still add another entry to your PATH when you type "su" in your shell.
[Asus Transformer TF700] elfaure:
Ah, ha. I see we are not quite done here yet. You are ABSOLUTELY right. I wasn't following you but now I see the light. Removing the {} around PATH did nothing. I failed to duplicate the experiment because I didn't su before I echoed $PATH when I checked the result.

u0_a87@android:/ $ echo $PATH
/system/bin:/system/xbin:/Removable/MicroSD/Scripts
u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # echo $PATH
/system/bin:/system/xbin:/Removable/MicroSD/Scripts:/Removable/MicroSD/Scripts
u0_a87@android:/ # su
u0_a87@android:/ # echo $PATH
/system/bin:/system/xbin:/Removable/MicroSD/Scripts:/Removable/MicroSD/Scripts:/Removable/MicroSD/Scripts
u0_a87@android:/ #
[Asus Transformer TF700] elfaure:
for p in ~/.bin /Removable/MicroSD/Scripts; do
[[ -d $p/. ]] || continue
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
done

Did the latter and it works PERFECTLY. I will NEVER doubt you again [MENTION=4878287]_that[/MENTION]. Not that I did and I knew this would work but I thought I had fixed it myself an easier way. I have learned my lesson. If there was an easier way you would have already seen it and pointed me there.

Is there any way to make the appended path come after /system/bin and /system/xbin rather than before? Would this do it? But then it would be effectively the same thing I had before and loop in nested su shells right? No, it gets even worse. It would go once for /system/bin, then again for /system/xbin, then again for each additional su shell you ran. Forget that, dumb idea.

for p in ~/.bin; do
[[ -d $p/. ]] || continue
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH:/Removable/MicroSD/Scripts
done

[Edit] Tried the above and it didn't work as expected, but didn't do any of the things I thought it would do either (displays my ignorance and reconfirms my nOOb status). As a matter of fact, it didn't do anything at all. Nothing added, nothing lost from the standard path.

Also I found this to be a VERY interesting exercise in finding code that works one way from the terminal from a root shell and quite differently when executed in a root script. I will have to go back and analyze its failure mode in the mkshrc edit before I'll ever be able to understand how you knew where to add the path in that code. I guess since its executed for each root shell and my code appends to the $PATH (over and over) that wasn't the correct approach and your edit was the only way to do it and the only place to put it (unless the above works also). Thanks (again, again).

u0_a87@android:/ $ echo $PATH
/Removable/MicroSD/Scripts:/system/bin:/system/xbin
u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # echo $PATH
/Removable/MicroSD/Scripts:/system/bin:/system/xbin
u0_a87@android:/ # su
u0_a87@android:/ # echo $PATH
/Removable/MicroSD/Scripts:/system/bin:/system/xbin
u0_a87@android:/ #