Can someone clean up this part of bin bash script for me? I feel like i can write this so much cleaner.
Basically, what i want to do is:
- If
$pluginexcl2
is defined that 2 differentgrep -v
will be used - If
$pluginexcl1
is defined than only 1grep -v
- If both are undefined, not to use
grep -v
.
Help is appreciated.
# Snygga curl koden
curl_url=$(curl -s https://api.github.com/repos/${pluginrepo}/releases/latest)
# Filtrera grep :D
if [ -n "${pluginexcl1}" ] && [ -n "${pluginexcl2}" ]; then
echo "$curl_url" | grep -wo "$plugingrep" | grep -v "$pluginexcl1" | grep -v "$pluginexcl2" | wget -qi - -O "${pluginfile}"
elif [ -n "${pluginexcl1}" ]; then
echo "$curl_url" | grep -wo "$plugingrep" | grep -v "$pluginexcl1" | wget -qi - -O "${pluginfile}"
else
echo "$curl_url" | grep -wo "$plugingrep" | wget -qi - -O "${pluginfile}"
fi
https://shellcheck.net
, a syntax checker, or installshellcheck
locally. Make usingshellcheck
part of your development process.