empty and script utilities for Easy Containers
Prior to releasing Easy 0.9.7, there was a problem with launching
apps in containers. For 'audacious' (music player) for example, a
desktop icon is created, clicking on it runs
/usr/sbin/ec-chroot-audacious, which has this in it:
#!/bin/sh
ec-chroot audacious
...which failed, yet does work from a terminal window and from the JWM menu, as I reported here:
http://bkhome.org/news/201810/easyos-pyro-097-almost-ready.html
I fixed it for 0.9.7, like this:
#!/bin/sh
urxvt -name eclaunch -iconic -e ec-chroot audacious
...where "-iconic" will launch the urxvt window minimized, and the
name "eclaunch" is recognised by JWM to hide the window. This is clumsy,
but it works.
Something in the 'ec-chroot-audacious' script is expecting the script
to have been launched from a terminal. As it hasn't, in the case of
ROX-Filer, there is a failure -- though interesting, can launch from the
JWM menu OK.
I did some more research on this, and found this excellent discussion:
https://stackoverflow.com/questions/32910661/pretend-to-be-a-tty-in-bash-for-any-command
...the example is given of the 'ls' command. This checks if run in a
terminal or in a script, and if the former, outputs with
color-highlighted text. In a script, you just want plain text, for
parsing purposes. So, that is the gist of the situation, something in
'ec-chroot-audacious' is performing a test, can't find a terminal, and
aborts ...or something like that.
The above reference describes using the 'script' command, which fortuitously is a busybox applet. Yes, it works:
#!/bin/sh
script -q -c "ec-chroot audacious" /dev/null
...clicking on the desktop icon, I can see the new pseudo-tty node
getting creating in /dev/pts, and removed when quit audacious.
The above link also mentions a command named 'empty', project page here:
That also works:
#!/bin/sh
empty -f ec-chroot audacious
...empty also created named pipes in /tmp, for input and output, though I don't see that I would need them.
Here is another interesting read:
https://stackoverflow.com/questions/1401002/trick-an-application-into-thinking-its-stdout-is-a-terminal-not-a-pipe/1401557#1401557
EDIT 2018-10-17:
Decided to use 'empty'. It is now compiled in oe-qky-src:
https://github.com/bkauler/oe-qky-src/tree/master/quirky/meta-quirky/recipes-quirky/empty
Tags: easy