trangetest: match @VAL@ string in cmd - numtools - perform numerical operations on vectors and matrices in unix pipes
 (HTM) git clone git://src.adamsgaard.dk/numtools
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 6a1c8bfa5f29e9f9ecf851d00f1a0210dac325bf
 (DIR) parent 75d269fb6d9921f0090d9ec5ddf7880d25fd0247
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Wed, 13 Jan 2021 15:33:56 +0100
       
       rangetest: match @VAL@ string in cmd
       
       Diffstat:
         M rangetest                           |      14 +++++++-------
       
       1 file changed, 7 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/rangetest b/rangetest
       t@@ -1,9 +1,9 @@
        #!/usr/bin/awk -f
        # uses a binary search to run a "cmd" where the first occurence of
       -# string @PARAM@ is substituted for a value between "min_val" and
       -# max_val".  Successful runs are reported on stdout, failed runs on
       -# stderr.  The "cmd" command must successfully run with either "min_val"
       -# or "max_val".
       +# string @VAL@ is substituted for a value between "min_val" and
       +# "max_val".  Successful runs are reported on stdout, failed runs
       +# on stderr.  The "cmd" command must successfully run with either
       +# "min_val" or "max_val".
        
        function die(s) {
                printf "error: %s\n", s > "/dev/stderr"
       t@@ -11,7 +11,7 @@ function die(s) {
        }
        
        function launch(cmd, val) {
       -        sub(/@PARAM@/, val, cmd)
       +        sub(/@VAL@/, val, cmd)
                if (system(cmd)) {
                        printf "%g\n", val > "/dev/stderr"
                        return 1
       t@@ -65,8 +65,8 @@ BEGIN {
                min = ARGV[2]
                max = ARGV[3]
        
       -        if (!match(cmd, /@PARAM@/))
       -                die("@PARAM@ not found in cmd")
       +        if (!match(cmd, /@VAL@/))
       +                die("@VAL@ not found in cmd")
        
                if (min >= max)
                        die("min_val must be smaller than max_val")