Bash: How can I check the return value of a command
<p>I am new to bash scripting and want to write a short script, that checks if a certain program is running. If it runs, the script should bring the window to the foreground, if it does not run, the script should start it.</p>

<pre><code>#!/bin/bash

if [ "$(wmctrl -l | grep Wunderlist)" = ""]; then
    /opt/google/chrome/google-chrome --profile-directory=Default --app-id=ojcflmmmcfpacggndoaaflkmcoblhnbh
else
    wmctrl -a Wunderlist
fi
</code></pre>

<p>My comparison is wrong, but I am not even sure what I should google to find a solution. My idea is, that the <code>"$(wmctrl -l | grep Wunderlist)"</code> will return an empty string, if the window does not exist. I get this error when I run the script:</p>

<pre><code>~/bin » sh handle_wunderlist.sh                                       
handle_wunderlist.sh: 3: [: =: argument expected
</code></pre>