When shellcheck is running from a snap it will get a private /tmp. Scripts are
generated in a workdir that is places under /tmp, but inside the host mount
namespace, thus the file will not be accessible by shellcheck.
Work around that by feeding the script to be checked through stdin.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Shell is deceivingly easy to write. It's best that we run the test snippets
through shellcheck.
This adds ~2s to whole suite execution time on my box.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
This comes as a result of investigating a failure of
SnapSuite.TestSnapRunAppWithStraceIntegration on Arch. In this particular case,
/bin/sh is symlinked to bash, thus `echo` is actually a [/usr]/bin/echo coming
from coreutils.
strace command in the test is called like this (sans the newlines and \):
sudo -E <strace-path> -u maciek -f \
-e !select,pselect6,_newselect,clock_gettime \
<snap-confine-path> \
snap.snapname.app \
/usr/lib/snapd/snap-exec \
snapname.app --arg1 arg2
Then the piece of shell script is expected to save each argument in a separate
line, with the script:
for arg in "$@"; do
echo "$arg" >> %[1]q
done
the arguments -E and -e will be called like this:
echo "-E" <-- actually /usr/bin/echo "-E"
echo "-e"
According to echo(1) both -e and -E are valid arguments and will be 'swallowed'
by the command, thus never appearing in the output.
Fix this by using a printf which does not have this problem.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>