hexive / sunpaper

Dynamic wallpaper changes based on the sun.
https://github.com/hexive/sunpaper
Apache License 2.0
197 stars 7 forks source link

Grep complains about stray backslash with weather enabled #26

Closed mklein994 closed 3 months ago

mklein994 commented 3 months ago

When I run the sunpaper command as a daemon with weather enabled, I get a warning about a stray backslash:

$ sunpaper -d
grep: warning: stray \ before "
grep: warning: stray \ before "
grep: warning: stray \ before "
grep: warning: stray \ before "
The Sunpaper daemon has started -- use sunpaper.sh -k to stop it.

I'm pretty sure it's because the grep string has some unnecessary escapes:

$ echo '"foo"' | grep '\"foo\"'
grep: warning: stray \ before "
grep: warning: stray \ before "
"foo"

Specifically this line is suspect: https://github.com/hexive/sunpaper/blob/main/sunpaper.sh#L637


$ grep --version
grep (GNU grep) 3.11
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others; see
<https://git.savannah.gnu.org/cgit/grep.git/tree/AUTHORS>.

grep -P uses PCRE2 10.44 2024-06-07
hexive commented 3 months ago

yeah, that line should probably have single quotes:

weather_main=$(echo "$weather_info" | grep -o -e '"main":"[a-zA-Z]*"' | awk -F ':' '{print $2}' | tr -d '"')
hexive commented 3 months ago

thanks for letting me know!