Example:
#!/bin/sh
a() {
R=f
ls -1 a*
[ "$?" == "1" ] && { R=t; }
echo $R
}
r=`a`
echo $r
$r contains "t" or "f" but also the output of the "ls" command.
I may write ls -1 a* >/dev/null 2>/dev/null, but if there is a more complex script that can be lead to errors.
Is there any way to return a single value from a() ?