I have written some code for downloading favicons. It has a logical error which I am not able to see.
#!/bin/bash
ico="1";
if [[ $ico =~ ^-?[0-9]+$ ]]; then
wget -P $HOME/Downloads/ http://www.google.com/favicon.ico
elif [[ $ico -eq 1 ]]; then
wget -P $HOME/Downloads/ http://www.cnet.com/favicon.ico
elif [[ $ico -eq 3 ]]; then
wget -P $HOME/Downloads/ https://www.facebook.com/favicon.ico
else
wget -P $HOME/Downloads/ https://www.twitter.com/favicon.ico
fi
According to my logic, when the variable ico
is 1
it should download favicons from both Google and CNet, as it satisfies both conditions (it is an integer and it has the value of 1). However, it only downloads Google’s favicon, not CNet’s.