Timeline for Expansion of variables in double square brackets
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 23, 2019 at 12:37 | comment | added | Student | Then I should decide if to add 24h to $now based on if it is larger than $start. I ended up writing another function if_within() to make the code in main() clearer.. | |
| Jul 23, 2019 at 12:30 | comment | added | Kamil Maciorowski | @Student What stops you? | |
| Jul 23, 2019 at 12:27 | comment | added | Student | @KamilMaciorowski I also want to compare them with $now. | |
| Jul 23, 2019 at 1:06 | comment | added | Kamil Maciorowski | If end before start, add 24h to end. If now before start, add 24h to now. Then compare. | |
| Jul 22, 2019 at 20:35 | comment | added | Student | I want my script to run between certain time, for example between 10am to 9:30pm: start=100000; end=213000. The problem is when end is over midnight, e.g. end=020000, I want $now to be larger than $start OR smaller than $end instead of AND. Is there another nonverbose way to do it? | |
| Jul 22, 2019 at 17:30 | answer | added | Freddy | timeline score: 1 | |
| Jul 22, 2019 at 16:13 | comment | added | glenn jackman | Even though it will be more verbose code, you're going to be better off just using an if or case based on $And rather than trying to shoe-horn it into the [[ command. | |
| Jul 22, 2019 at 15:08 | comment | added | user313992 | I'm really skeptical that would simplify your code. But if you're curious how bash works, then please notice that [[ a > b ]] will do a lexicographical comparison on its operands: [[ 2 > 11 ]] && echo 2 is greater than 11 (and to add insult to injury, they'll do it using the current locale ;-)). | |
| Jul 22, 2019 at 13:24 | comment | added | ilkkachu | I don't think you can do that without eval (which might involve quoting hell with the other parts of your test). Can you show what you're trying to achieve in the end? Perhaps there might be some other way to do what you want. | |
| Jul 22, 2019 at 13:21 | history | asked | Student | CC BY-SA 4.0 |