osx - Bash if statement which saves variable to config file doesn't work -
this code:
alias radio=' if [ -e "$station" ] open $station else "i still don't know favorite radio station sir. mind giving me link?" echo "what link of favorite station?" read station echo "station="$station"" >> ~/.fis/config "you can try command again." fi'
the code runs part asks link. when provide link following error:
-bash: station=http://www.cidadefm.iol.pt/player/player.html?: no such file or directory
does have idea of might wrong?
the main problem using $station
outside of quotes. there's &
breaking command.
you seem use "station" variable name 2 different purposes. that's confusing.
also, kind of awkward put alias. i'd use function
radio () { local file=~/.fis/config if [ -f "$file" ] station=$(< "$file") else "i still don't know favorite radio station sir. mind giving me link?" echo "what url of favorite station?" read staton echo "$station" > "$file" fi open "$station" }
Comments
Post a Comment