Timeline for bash + compare variable with spaces
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 2, 2017 at 18:28 | comment | added | DopeGhoti | It's still good practice to put the constant on the LHS, just so that you don't have to think about whether you're in a context where it matters or not. As to quotes, I may have been mistaken about needing them, but similarly, I tend to err on the side of "quote everything" out of an abundance of caution. | |
| Nov 2, 2017 at 18:21 | comment | added | yael | please advice why this not works ?? - [[ "not running" =~ $STAT ]] or [[ "not running" =~ "$STAT" ]] | |
| Nov 2, 2017 at 18:13 | comment | added | ilkkachu | @JeffSchaller, that only applies to languages where assignments work in arbitrary expressions, and for compilers that are dumb enough not to warn about it. | |
| Nov 2, 2017 at 18:12 | comment | added | ilkkachu | shell assignment doesn't need quotes, and neither does [[ .. ]]. try something like bash -c 'stat=$(echo "not running"); [[ $stat = "not running" ]] && echo yes | |
| Nov 2, 2017 at 18:04 | comment | added | Jeff Schaller♦ | +1 just for the good programming practice of putting the constant on the left of the equals sign. | |
| Nov 2, 2017 at 18:00 | history | answered | DopeGhoti | CC BY-SA 3.0 |