Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm mostly a ksh person, but my experience with bash says this should work (given your example), or at least point you towards what needs to be done.</p> <pre><code>hrVal=6 case ${hrVal} in 1|[5-7]|16 ) print -- "true" ;; * ) print -- "false" ;; esac </code></pre> <p><strong>Edit 2018-08-20</strong> For <code>bash</code>, you'll need to change <code>print --</code> to either <code>echo ....</code> or <code>printf "%s\n"</code>.</p> <p>In reality, I would remove the <code>print -- ""</code> stuff, and just call <code>exit 0</code> or <code>exit 1</code>, which will then exit with the appropriate return code, that can then be tested by the calling process.</p> <hr> <p>to include the rest of your example, I had to do</p> <pre><code> hrVal=6 eval " case ${hrVal} in 1|[5-7]|16|$(( ${hrVal} / 3 )) ) print -- "true" ;; * ) print -- "false" ;; esac " </code></pre> <p>So, this could be exciting!</p> <ul> <li>Parse each of 5 time bands as above </li> <li>apply sed like commands to convert he entries like 1,5-7,16 into 1|[5-7]|16</li> <li>trap and convert your math expressions into evaluatable expressions (oh, you can probably get the result before the case statement and just merge the value into the ....) save all derived values as variables,</li> <li>use those variables as case targets, possible wrapping the whole thing and escaping chars as needed with an eval.</li> <li>evaluate the combined truth of all 5 columns return values (any false == false)</li> </ul> <p>(maybe it is (( ${hrVal} / 3 )) in bash )</p> <p>IHTH</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload