I wrote a little helper to start an Android emulator which looks like this:
# START ANDROID EMULATION
android-sim () {
if [[ -z "$1" ]]; then
echo "No Android device supplied as argument!"
return 1
fi
if [[ -d "$ANDROID_HOME" ]]; then
cd "$ANDROID_HOME/emulator" &>/dev/null
./emulator "@$1" &>/dev/null &
cd - &>/dev/null
else
echo "The variable ANDROID_HOME is not set to a correct directory!"
fi
}
I tried to suppress all the generated output with &>/dev/null
. For the emulator
itself I also tried to put the execution in the background.
But when I run the function I still get the following output:
# before exeuction
[09:11:48] sandrowinkler:~ $ android-sim pixel-29
[1] 23217
# after execution, I closed the emulator via GUI
[09:11:55] sandrowinkler:~ $
[1]+ Done ./emulator "@$1" &> /dev/null
(wd: /usr/local/share/android-sdk/emulator)
(wd now: ~)
According to this superuser post and this unix post I used the right way to silence the output. So what am I doing wrong here?
PS: I would also appreciate tips to improve my Bash code.