I have a small problem with a script that I am making for Android. I can't seam to get 'EOF' to work in 'mksh'. It is working fine in 'sh' and 'bash', but since 'mksh' is becomming the most used in Android I really need for it to work in all.
cat <<EOF
... lines here ...
EOF
This example will cause the fallowing error
can't create temporary file /sqlite_stmt_journals/mksh.(random): No such file or directory
I have seen others with this issue, but no real solution.
The problem comes from that /sqlite_stmt_journals used to exist and be a world-writable sticky directory, like /tmp is in normal Unix boxen, so I used it as standard TMPDIR when I added mksh to Android.
Recent Android security policy forbids world-writable directories, totally.
We (the Android team and I) are aware of the problem but have yet to come up with a good solution; “user” home directories would need to be created before they can be (automatically) used, but a Googler told me they have something in the queue.
Until then, set TMPDIR to something that is writable for your user.
This is a problem with the Android environment, not with mksh per se.
@Julian Fondren: your Android device is probably from when that directory still existed.
In AOSP git master, the default TMPDIR is /data/local which is writable at least for the root user… so, just set it to something writable for you (and export it if you’re running scripts) for now.
Well, there's this obvious if unpleasant solution: don't use HERE docs; just echo each line to a temporary file. So your example becomes:
echo ... first line ... > $tmpfile
echo ... subsequent lines ... >> $tmpfile
cat $tmpfile
rm $tmpfile
EDIT: wait, what? Sure looks like HERE docs work just fine on mksh to me. The following occurs with mksh R39 on a stock Kindle Fire HD (don't mind the perl):
$ perl <<FOO
print "hi\n"
FOO
hi
$
Your example also works as I'd expect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With