The script
#!/system/bin/sh
/system/bin/busybox find .
f=$(/system/bin/busybox find .)
echo $f
for f in $(/system/bin/busybox find .)
do
echo $f
done
does not work as expected in my environment. I get:
.
./loop.sh
while
bash loop.sh
.
./loop.sh
. ./loop.sh
.
./loop.sh
is the result for the equivalent on a linux box:
#!/bin/sh
find .
f=$(find .)
echo $f
for f in $(find .)
do
echo $f
done
What can I do about this?
The environment is:
getprop ro.build.version.sdk
22
getprop ro.build.version.release
5.1.1
busybox
BusyBox v1.22.1 (2014-09-16 09:27:06 CST) multi-call binary.
busybox uname -a
Linux localhost 3.14.0 #68 SMP PREEMPT Wed Jan 18 10:27:06 CST 2017 i686 GNU/Linux
/bin/sh
is something else than/bin/bash
(e.g. doesn't support as many things as Bash does). Have you tried how that script works on Linux when using#!/bin/sh
instead of#!/bin/bash
? Or on your Android device when using Bash (if you have it available there that is)? – Izzy May 12 '17 at 09:20sh
on the Android device? As for Bash on Android: my corresponding app list says there is e.g. Bash Shell X you could give a try (if you don't mind it coming with AdMob; otherwise Termius also includes a local Bash). – Izzy May 12 '17 at 09:39find
compared to your Linux Distro.. BTW, what is your script trying to achieve? If it's simply listing the contents of a directory, you could better usels
, and pipe it togrep
for searching.. – Gokul NC May 12 '17 at 14:00