• Daniel Black's avatar
    wsrep_sst_common: parse_cnf - use awk rather than grep/cut/tail excessiveness · 95e5fe67
    Daniel Black authored
    Test cases:
    
    f($var) = awk -v var="${var}"  \
         'BEGIN { OFS=FS="="}
         { gsub(/_/,"-",$1); if ( $1=="--"var ) lastval=substr($0,length($1)+2) }
         END { print lastval }'
    
    Missing input is blank:
    
    $ echo '--var_aa=something' | f(var-b-not-ther)
    (blank as expected)
    
    All RHS of = is unmunged:
    
    $ echo '--var_aa=password==_-$' | f(var-aa)
    password==_-$
    
    Mixed - and _ in var name:
    $ echo '--var_aa-bb_cc=1' | f(var-aa-bb-cc)
    1
    
    No value returns blank line:
    $ echo '--var_aa-bb_cc' | f(var-aa-bb-cc)
    (blank line as expected)
    
    Multiples return the last:
    $  echo -e "--bb=cc\n--bb=dd" | f(bb)
    dd
    95e5fe67
wsrep_sst_common.sh 6.78 KB