# Copyright (C) 2016, 2017, 2018, 2019  Stefan Vargyas
# 
# This file is part of Json-Type.
# 
# Json-Type is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# Json-Type is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Json-Type.  If not, see <http://www.gnu.org/licenses/>.

#
# json filter test suite:
#

$ . ~/regtest2.sh
$ alias json-filter-regtest='regtest2-selftest -f test-json-filter.txt -a exec=pipe -B'

# output all test names:
$ json-filter-regtest -N
...

# run all tests:
$ json-filter-regtest -A

--[ prereq ]--------------------------------------------------------------------

$ json0() { LD_LIBRARY_PATH=../lib ../src/json "$@"; }
$

--[ no-groups ]-----------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json=json0
$ json -F
json: error: action `-F|--filterlib-exec' requires at least one filter command line arguments group
command failed: json -F
$ json -f
json: error: option `-f|--filter-libs' requires at least one filter command line arguments group
command failed: json -f
$

--[ empty-groups ]--------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json='json0 -f'
$ json --
json: error: empty filter arguments group #1
command failed: json --
$ json -- --
json: error: empty filter arguments group #1
command failed: json -- --
$ json -- -- a
json: error: empty filter arguments group #1
command failed: json -- -- a
$ json -- -- a --
json: error: empty filter arguments group #1
command failed: json -- -- a --
$ json -- a --
json: error: empty filter arguments group #2
command failed: json -- a --
$ json -- a -- --
json: error: empty filter arguments group #2
command failed: json -- a -- --
$ json -- a -- -- b
json: error: empty filter arguments group #2
command failed: json -- a -- -- b
$ json -- a -- -- b --
json: error: empty filter arguments group #2
command failed: json -- a -- -- b --
$ json -- a -- b --
json: error: empty filter arguments group #3
command failed: json -- a -- b --
$ json -- a -- b -- --
json: error: empty filter arguments group #3
command failed: json -- a -- b -- --
$ json -- a -- b -- -- c
json: error: empty filter arguments group #3
command failed: json -- a -- b -- -- c
$ json -- a -- b -- -- c --
json: error: empty filter arguments group #3
command failed: json -- a -- b -- -- c --
$ json -- a -- b -- c --
json: error: empty filter arguments group #4
command failed: json -- a -- b -- c --
$ json -- a -- b -- c -- --
json: error: empty filter arguments group #4
command failed: json -- a -- b -- c -- --
$ json -- a -- b -- c -- -- d
json: error: empty filter arguments group #4
command failed: json -- a -- b -- c -- -- d
$ json -- a -- b -- c -- -- d --
json: error: empty filter arguments group #4
command failed: json -- a -- b -- c -- -- d --
$

--[ empty-groups2 ]-------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json='json0 -F'
$ json --
json: error: empty filter arguments group #1
command failed: json --
$ json -- --
json: error: empty filter arguments group #1
command failed: json -- --
$ json -- -- a
json: error: empty filter arguments group #1
command failed: json -- -- a
$ json -- -- a --
json: error: empty filter arguments group #1
command failed: json -- -- a --
$ json -- a --
json: error: empty filter arguments group #2
command failed: json -- a --
$ json -- a -- --
json: error: empty filter arguments group #2
command failed: json -- a -- --
$ json -- a -- -- b
json: error: empty filter arguments group #2
command failed: json -- a -- -- b
$ json -- a -- -- b --
json: error: empty filter arguments group #2
command failed: json -- a -- -- b --
$ json -- a -- b --
json: error: empty filter arguments group #3
command failed: json -- a -- b --
$ json -- a -- b -- --
json: error: empty filter arguments group #3
command failed: json -- a -- b -- --
$ json -- a -- b -- -- c
json: error: empty filter arguments group #3
command failed: json -- a -- b -- -- c
$ json -- a -- b -- -- c --
json: error: empty filter arguments group #3
command failed: json -- a -- b -- -- c --
$ json -- a -- b -- c --
json: error: empty filter arguments group #4
command failed: json -- a -- b -- c --
$ json -- a -- b -- c -- --
json: error: empty filter arguments group #4
command failed: json -- a -- b -- c -- --
$ json -- a -- b -- c -- -- d
json: error: empty filter arguments group #4
command failed: json -- a -- b -- c -- -- d
$ json -- a -- b -- c -- -- d --
json: error: empty filter arguments group #4
command failed: json -- a -- b -- c -- -- d --
$

--[ multi-groups ]--------------------------------------------------------------

$ json() { set -o pipefail && json0 --dump-opt "$@"|sed -nr '/^filter-libs/p'; }
$ json -F
filter-libs:                   -
$ json -F -- a
filter-libs[0][0]:             a
$ json -F -- a b c
filter-libs[0][0]:             a
filter-libs[0][1]:             b
filter-libs[0][2]:             c
$ json -F -- a b c -- d e
filter-libs[0][0]:             a
filter-libs[0][1]:             b
filter-libs[0][2]:             c
filter-libs[1][0]:             d
filter-libs[1][1]:             e
$ json -F -- a b c -- d e -- f
filter-libs[0][0]:             a
filter-libs[0][1]:             b
filter-libs[0][2]:             c
filter-libs[1][0]:             d
filter-libs[1][1]:             e
filter-libs[2][0]:             f
$ json -f
filter-libs:                   -
$ json -f -- a
filter-libs[0][0]:             a
$ json -f -- a b c
filter-libs[0][0]:             a
filter-libs[0][1]:             b
filter-libs[0][2]:             c
$ json -f -- a b c -- d e
filter-libs[0][0]:             a
filter-libs[0][1]:             b
filter-libs[0][2]:             c
filter-libs[1][0]:             d
filter-libs[1][1]:             e
$ json -f -- a b c -- d e -- f
filter-libs[0][0]:             a
filter-libs[0][1]:             b
filter-libs[0][2]:             c
filter-libs[1][0]:             d
filter-libs[1][1]:             e
filter-libs[2][0]:             f
$ json -F -- 1 -- 2 -- 3 -- 4 -- 5 -- 6 -- 7 -- 8 -- 9 -- 10 -- 11 -- 12 -- 13 -- 14 -- 15 -- 16
filter-libs[0][0]:             1
filter-libs[1][0]:             2
filter-libs[2][0]:             3
filter-libs[3][0]:             4
filter-libs[4][0]:             5
filter-libs[5][0]:             6
filter-libs[6][0]:             7
filter-libs[7][0]:             8
filter-libs[8][0]:             9
filter-libs[9][0]:             10
filter-libs[10][0]:            11
filter-libs[11][0]:            12
filter-libs[12][0]:            13
filter-libs[13][0]:            14
filter-libs[14][0]:            15
filter-libs[15][0]:            16
$ json -f -- 1 -- 2 -- 3 -- 4 -- 5 -- 6 -- 7 -- 8 -- 9 -- 10 -- 11 -- 12 -- 13 -- 14 -- 15 -- 16
filter-libs[0][0]:             1
filter-libs[1][0]:             2
filter-libs[2][0]:             3
filter-libs[3][0]:             4
filter-libs[4][0]:             5
filter-libs[5][0]:             6
filter-libs[6][0]:             7
filter-libs[7][0]:             8
filter-libs[8][0]:             9
filter-libs[9][0]:             10
filter-libs[10][0]:            11
filter-libs[11][0]:            12
filter-libs[12][0]:            13
filter-libs[13][0]:            14
filter-libs[14][0]:            15
filter-libs[15][0]:            16
$ shopt -s expand_aliases
$ unset -f json && alias json='json0 --dump-opt'
$ json -F -- 1 -- 2 -- 3 -- 4 -- 5 -- 6 -- 7 -- 8 -- 9 -- 10 -- 11 -- 12 -- 13 -- 14 -- 15 -- 16 -- 17
json: error: too many filter arguments groups (max is 16)
command failed: json -F -- 1 -- 2 -- 3 -- 4 -- 5 -- 6 -- 7 -- 8 -- 9 -- 10 -- 11 -- 12 -- 13 -- 14 -- 15 -- 16 -- 17
$ json -f -- 1 -- 2 -- 3 -- 4 -- 5 -- 6 -- 7 -- 8 -- 9 -- 10 -- 11 -- 12 -- 13 -- 14 -- 15 -- 16 -- 17
json: error: too many filter arguments groups (max is 16)
command failed: json -f -- 1 -- 2 -- 3 -- 4 -- 5 -- 6 -- 7 -- 8 -- 9 -- 10 -- 11 -- 12 -- 13 -- 14 -- 15 -- 16 -- 17
$

--[ ignore-opt ]----------------------------------------------------------------

$ json() { json0 "$@" <<< '"null"'; }
$ json -S -- ./foo.so
json: warning: ignoring the filter command line arguments since neither `-F|--filterlib-exec' nor `-f|--filter-libs' were given
\"null\"\n
$ json -Tp -- ./foo.so
json: warning: ignoring the filter command line arguments since neither `-F|--filterlib-exec' nor `-f|--filter-libs' were given
"null"
$ json -S -f -- ./foo.so
json: warning: ignoring the filter command line arguments since none of JSON parser, printer or flattener options were given
\"null\"\n
$ json -Tp -f -- ./foo.so
json: warning: ignoring the filter command line arguments since none of JSON parser, printer or flattener options were given
"null"
$

--[ dyn-lib ]-------------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json=json0
$ json -F -
json: error: input filter library cannot be stdin
command failed: json -F -
$ json -F -- -
json: error: -: filter library: failed loading library
command failed: json -F -- -
$ json -V -F -- -
json: error: -: filter library: failed loading library: dlopen failed: -: cannot open shared object file: No such file or directory
command failed: json -V -F -- -
$ json -f -- -
json: error: -: filter library: failed loading library
command failed: json -f -- -
$ json -V -f -- -
json: error: -: filter library: failed loading library: dlopen failed: -: cannot open shared object file: No such file or directory
command failed: json -V -f -- -
$ json -F /dev/null
json: error: /dev/null: filter library: failed loading library
command failed: json -F /dev/null
$ json -F -- /dev/null
json: error: /dev/null: filter library: failed loading library
command failed: json -F -- /dev/null
$ json -V -F -- /dev/null
json: error: /dev/null: filter library: failed loading library: dlopen failed: /dev/null: file too short
command failed: json -V -F -- /dev/null
$ json -f -- /dev/null
json: error: /dev/null: filter library: failed loading library
command failed: json -f -- /dev/null
$ json -V -f -- /dev/null
json: error: /dev/null: filter library: failed loading library: dlopen failed: /dev/null: file too short
command failed: json -V -f -- /dev/null
$

--[ dyn-lib2 ]------------------------------------------------------------------

$ json() { json0 -F "$@"; }
$ json ./foo.so
json: error: ./foo.so: filter library: failed loading library
command failed: json ./foo.so
$ json -- ./foo.so
json: error: ./foo.so: filter library: failed loading library
command failed: json -- ./foo.so
$ json -- ./foo.so a b c
json: error: ./foo.so: filter library: failed loading library
command failed: json -- ./foo.so a b c
$ json -- ./foo.so -- ./bar.so
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
json: error: ./foo.so: filter library: failed loading library
command failed: json -- ./foo.so -- ./bar.so
$ json -- ./foo.so a b c -- ./bar.so d e
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
json: error: ./foo.so: filter library: failed loading library
command failed: json -- ./foo.so a b c -- ./bar.so d e
$ json -V ./foo.so
json: error: ./foo.so: filter library: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V ./foo.so
$ json -V -- ./foo.so
json: error: ./foo.so: filter library: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V -- ./foo.so
$ json -V -- ./foo.so a b c
json: error: ./foo.so: filter library: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V -- ./foo.so a b c
$ json -V -- ./foo.so -- ./bar.so
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
json: error: ./foo.so: filter library: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V -- ./foo.so -- ./bar.so
$ json -V -- ./foo.so a b c -- ./bar.so d e
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
json: error: ./foo.so: filter library: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V -- ./foo.so a b c -- ./bar.so d e
$ json() { json0 -f "$@" <<< ''; }
$ json -- ./foo.so
json: error: ./foo.so: filter library: failed loading library
command failed: json -- ./foo.so
$ json -- ./foo.so a b c
json: error: ./foo.so: filter library: failed loading library
command failed: json -- ./foo.so a b c
$ json -- ./foo.so -- ./bar.so
json: error: ./foo.so: filter library #1: failed loading library
command failed: json -- ./foo.so -- ./bar.so
$ json -- ./foo.so a b c -- ./bar.so d e
json: error: ./foo.so: filter library #1: failed loading library
command failed: json -- ./foo.so a b c -- ./bar.so d e
$ json -V ./foo.so
json: error: option `-f|--filter-libs' requires at least one filter command line arguments group
command failed: json -V ./foo.so
$ json -V -- ./foo.so
json: error: ./foo.so: filter library: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V -- ./foo.so
$ json -V -- ./foo.so a b c
json: error: ./foo.so: filter library: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V -- ./foo.so a b c
$ json -V -- ./foo.so -- ./bar.so
json: error: ./foo.so: filter library #1: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V -- ./foo.so -- ./bar.so
$ json -V -- ./foo.so a b c -- ./bar.so d e
json: error: ./foo.so: filter library #1: failed loading library: dlopen failed: ./foo.so: cannot open shared object file: No such file or directory
command failed: json -V -- ./foo.so a b c -- ./bar.so d e
$

--[ dyn-lib3 ]------------------------------------------------------------------

$ json() { json0 -F "$@"; }
$ json ../lib/test-type.so
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found
command failed: json ../lib/test-type.so
$ json -- ../lib/test-type.so
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-type.so
$ json -- ../lib/test-type.so a b c
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-type.so a b c
$ json -- ../lib/test-type.so -- ./foo.so
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-type.so -- ./foo.so
$ json -- ../lib/test-type.so a b c -- ./foo.so d e
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-type.so a b c -- ./foo.so d e
$ json -V ../lib/test-type.so
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V ../lib/test-type.so
$ json -V -- ../lib/test-type.so
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-type.so
$ json -V -- ../lib/test-type.so a b c
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-type.so a b c
$ json -V -- ../lib/test-type.so -- ./foo.so
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-type.so -- ./foo.so
$ json -V -- ../lib/test-type.so a b c -- ./foo.so d e
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-type.so a b c -- ./foo.so d e
$ json() { json0 -f "$@" <<< ''; }
$ json -- ../lib/test-type.so
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-type.so
$ json -- ../lib/test-type.so a b c
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-type.so a b c
$ json -- ../lib/test-type.so -- ./foo.so
json: error: ../lib/test-type.so: filter library #1: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-type.so -- ./foo.so
$ json -- ../lib/test-type.so a b c -- ./foo.so d e
json: error: ../lib/test-type.so: filter library #1: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-type.so a b c -- ./foo.so d e
$ json -V ../lib/test-type.so
json: error: option `-f|--filter-libs' requires at least one filter command line arguments group
command failed: json -V ../lib/test-type.so
$ json -V -- ../lib/test-type.so
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-type.so
$ json -V -- ../lib/test-type.so a b c
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-type.so a b c
$ json -V -- ../lib/test-type.so -- ./foo.so
json: error: ../lib/test-type.so: filter library #1: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-type.so -- ./foo.so
$ json -V -- ../lib/test-type.so a b c -- ./foo.so d e
json: error: ../lib/test-type.so: filter library #1: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-type.so a b c -- ./foo.so d e
$

--[ dyn-lib4 ]------------------------------------------------------------------

$ json() { json0 -F "$@"; }
$ json ../lib/test-filter.so -- ../lib/test-type.so
json: warning: action `-F|--filterlib-exec': ignoring the filter command line arguments since input file was given
usage: test-filter.so [ACTION|OPTION]...
where actions are specified as:
  -G|--generic         print out the text 'generic action'
the options are:
  -f|--fail=WHERE      set where the filter to fail or make
     --no-fail           it to not fail at all; WHERE can be
                         any of: 'init', 'handler' or 'exec'
  -d|--dump-options    print parsed options and exit
  -v|--version         print version numbers and exit
  -?|--help            display this help info and exit
$ json -- ../lib/test-filter.so -- ../lib/test-type.so
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
test-filter.so: generic action
$ json -- ../lib/test-filter.so -- ../lib/test-type.so a b c
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
test-filter.so: generic action
$ json -- ../lib/test-filter.so -- ../lib/test-type.so -- ./foo.so
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
test-filter.so: generic action
$ json -- ../lib/test-filter.so -- ../lib/test-type.so a b c -- ./foo.so d e
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
test-filter.so: generic action
$ json -V ../lib/test-filter.so -- ../lib/test-type.so
json: warning: action `-F|--filterlib-exec': ignoring the filter command line arguments since input file was given
usage: test-filter.so [ACTION|OPTION]...
where actions are specified as:
  -G|--generic         print out the text 'generic action'
the options are:
  -f|--fail=WHERE      set where the filter to fail or make
     --no-fail           it to not fail at all; WHERE can be
                         any of: 'init', 'handler' or 'exec'
  -d|--dump-options    print parsed options and exit
  -v|--version         print version numbers and exit
  -?|--help            display this help info and exit
$ json -V -- ../lib/test-filter.so -- ../lib/test-type.so
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
test-filter.so: generic action
$ json -V -- ../lib/test-filter.so -- ../lib/test-type.so a b c
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
test-filter.so: generic action
$ json -V -- ../lib/test-filter.so -- ../lib/test-type.so -- ./foo.so
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
test-filter.so: generic action
$ json -V -- ../lib/test-filter.so -- ../lib/test-type.so a b c -- ./foo.so d e
json: warning: action `-F|--filterlib-exec': multiple filter command line arguments groups given
test-filter.so: generic action
$ json() { json0 -f "$@" <<< ''; }
$ json -- ../lib/test-filter.so -- ../lib/test-type.so
json: error: ../lib/test-type.so: filter library #2: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-filter.so -- ../lib/test-type.so
$ json -- ../lib/test-filter.so -- ../lib/test-type.so a b c
json: error: ../lib/test-type.so: filter library #2: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-filter.so -- ../lib/test-type.so a b c
$ json -- ../lib/test-filter.so -- ../lib/test-type.so -- ./foo.so
json: error: ../lib/test-type.so: filter library #2: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-filter.so -- ../lib/test-type.so -- ./foo.so
$ json -- ../lib/test-filter.so -- ../lib/test-type.so a b c -- ./foo.so d e
json: error: ../lib/test-type.so: filter library #2: 'filter_get_version' symbol not found
command failed: json -- ../lib/test-filter.so -- ../lib/test-type.so a b c -- ./foo.so d e
$ json -V ../lib/test-filter.so -- ../lib/test-type.so
json: error: ../lib/test-type.so: filter library: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V ../lib/test-filter.so -- ../lib/test-type.so
$ json -V -- ../lib/test-filter.so -- ../lib/test-type.so
json: error: ../lib/test-type.so: filter library #2: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-filter.so -- ../lib/test-type.so
$ json -V -- ../lib/test-filter.so -- ../lib/test-type.so a b c
json: error: ../lib/test-type.so: filter library #2: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-filter.so -- ../lib/test-type.so a b c
$ json -V -- ../lib/test-filter.so -- ../lib/test-type.so -- ./foo.so
json: error: ../lib/test-type.so: filter library #2: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-filter.so -- ../lib/test-type.so -- ./foo.so
$ json -V -- ../lib/test-filter.so -- ../lib/test-type.so a b c -- ./foo.so d e
json: error: ../lib/test-type.so: filter library #2: 'filter_get_version' symbol not found: dlsym failed: ../lib/test-type.so: undefined symbol: test_type_filter_get_version
command failed: json -V -- ../lib/test-filter.so -- ../lib/test-type.so a b c -- ./foo.so d e
$

--[ version ]-------------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json='json0 -F'
$ ../lib/test-filter.so
test-filter.so: version 0.1 -- 2018-06-28 13:44
test-filter.so: json filter version: 0.1.0
$ json -- ../lib/test-filter.so --version
test-filter.so: version 0.1 -- 2018-06-28 13:44
test-filter.so: json filter version: 0.1.0
$

--[ help ]----------------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json='json0 -F'
$ json ../lib/test-filter.so
usage: test-filter.so [ACTION|OPTION]...
where actions are specified as:
  -G|--generic         print out the text 'generic action'
the options are:
  -f|--fail=WHERE      set where the filter to fail or make
     --no-fail           it to not fail at all; WHERE can be
                         any of: 'init', 'handler' or 'exec'
  -d|--dump-options    print parsed options and exit
  -v|--version         print version numbers and exit
  -?|--help            display this help info and exit
$ json -- ../lib/test-filter.so --help
usage: test-filter.so [ACTION|OPTION]...
where actions are specified as:
  -G|--generic         print out the text 'generic action'
the options are:
  -f|--fail=WHERE      set where the filter to fail or make
     --no-fail           it to not fail at all; WHERE can be
                         any of: 'init', 'handler' or 'exec'
  -d|--dump-options    print parsed options and exit
  -v|--version         print version numbers and exit
  -?|--help            display this help info and exit
$

--[ invalid-args ]--------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json='json0 -F'
$ json -- ../lib/test-filter.so -X
json: error: ../lib/test-filter.so: filter library: invalid command line option '-X'
command failed: json -- ../lib/test-filter.so -X
$ json -- ../lib/test-filter.so --foo
json: error: ../lib/test-filter.so: filter library: invalid command line option '--foo'
command failed: json -- ../lib/test-filter.so --foo
$ json -- ../lib/test-filter.so -f
json: error: ../lib/test-filter.so: filter library: argument for option '-f' not found
command failed: json -- ../lib/test-filter.so -f
$ json -- ../lib/test-filter.so --fail
json: error: ../lib/test-filter.so: filter library: argument for option '--fail' not found
command failed: json -- ../lib/test-filter.so --fail
$ json -- ../lib/test-filter.so -f ''
json: error: ../lib/test-filter.so: filter library: invalid argument for 'fail' option: ''
command failed: json -- ../lib/test-filter.so -f ''
$ json -- ../lib/test-filter.so --fail=
json: error: ../lib/test-filter.so: filter library: invalid argument for 'fail' option: ''
command failed: json -- ../lib/test-filter.so --fail=
$ json -- ../lib/test-filter.so -f foo
json: error: ../lib/test-filter.so: filter library: invalid argument for 'fail' option: 'foo'
command failed: json -- ../lib/test-filter.so -f foo
$ json -- ../lib/test-filter.so --fail=foo
json: error: ../lib/test-filter.so: filter library: invalid argument for 'fail' option: 'foo'
command failed: json -- ../lib/test-filter.so --fail=foo
$ json -- ../lib/test-filter.so --no-fail=
json: error: ../lib/test-filter.so: filter library: option '--no-fail' does not allow an argument
command failed: json -- ../lib/test-filter.so --no-fail=
$ json -- ../lib/test-filter.so --no-fail=foo
json: error: ../lib/test-filter.so: filter library: option '--no-fail' does not allow an argument
command failed: json -- ../lib/test-filter.so --no-fail=foo
$

--[ invalid-args2 ]-------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json='json0 -f'
$ json -- ../lib/test-filter.so -X
json: error: ../lib/test-filter.so: filter library: invalid command line option '-X'
command failed: json -- ../lib/test-filter.so -X
$ json -- ../lib/test-filter.so --foo
json: error: ../lib/test-filter.so: filter library: invalid command line option '--foo'
command failed: json -- ../lib/test-filter.so --foo
$ json -- ../lib/test-filter.so -f
json: error: ../lib/test-filter.so: filter library: argument for option '-f' not found
command failed: json -- ../lib/test-filter.so -f
$ json -- ../lib/test-filter.so --fail
json: error: ../lib/test-filter.so: filter library: argument for option '--fail' not found
command failed: json -- ../lib/test-filter.so --fail
$ json -- ../lib/test-filter.so -f ''
json: error: ../lib/test-filter.so: filter library: invalid argument for 'fail' option: ''
command failed: json -- ../lib/test-filter.so -f ''
$ json -- ../lib/test-filter.so --fail=
json: error: ../lib/test-filter.so: filter library: invalid argument for 'fail' option: ''
command failed: json -- ../lib/test-filter.so --fail=
$ json -- ../lib/test-filter.so -f foo
json: error: ../lib/test-filter.so: filter library: invalid argument for 'fail' option: 'foo'
command failed: json -- ../lib/test-filter.so -f foo
$ json -- ../lib/test-filter.so --fail=foo
json: error: ../lib/test-filter.so: filter library: invalid argument for 'fail' option: 'foo'
command failed: json -- ../lib/test-filter.so --fail=foo
$ json -- ../lib/test-filter.so --no-fail=
json: error: ../lib/test-filter.so: filter library: option '--no-fail' does not allow an argument
command failed: json -- ../lib/test-filter.so --no-fail=
$ json -- ../lib/test-filter.so --no-fail=foo
json: error: ../lib/test-filter.so: filter library: option '--no-fail' does not allow an argument
command failed: json -- ../lib/test-filter.so --no-fail=foo
$

--[ dump-opts ]-----------------------------------------------------------------

$ shopt -s expand_aliases
$ alias json='json0 -F -- ../lib/test-filter.so --dump-opt'
$ json
action:    generic
fail:      none
argc:      0
argv:      -
$ json --no-fail
action:    generic
fail:      none
argc:      0
argv:      -
$ json --fail=init
json: error: ../lib/test-filter.so: filter library: init failure
command failed: json --fail=init
$ json --fail=handler
action:    generic
fail:      handler
argc:      0
argv:      -
$ json --fail=exec
action:    generic
fail:      exec
argc:      0
argv:      -
$

--[ no-fail ]-------------------------------------------------------------------

$ json() { json0 -F "$@"; }
$ json -- ../lib/test-filter.so --no-fail
test-filter.so: generic action
$ json() { json0 -f "$@" <<< '{"a":{"b":"c"}}'; }
$ json -- ../lib/test-filter.so --no-fail
/a/b=c
$

--[ fail-twice ]-----------------------------------------------------------------

$ json() { json0 -f "$@" <<< '{"a":{"b":"c"}}'; }
#
# # meta command:
# $ for i in init handler exec; do c="json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=$i -- ../lib/test-filter.so --fail=$i"; echo "$ $c"; done; for i in init handler exec; do c="json -- ../lib/test-filter.so --fail=$i -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=$i"; echo "$ $c"; done; for i in init handler exec; do c="json -- ../lib/test-filter.so --fail=$i -- ../lib/test-filter.so --fail=$i -- ../lib/test-filter.so --no-fail"; echo "$ $c"; done
#
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library #3: init failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=init
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=handler
json: error: <stdin>: filter library #2: handler failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=exec
/a/b=c
$ json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library #3: init failure
command failed: json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler
json: error: <stdin>: filter library #1: handler failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec
/a/b=c
$ json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail
json: error: ../lib/test-filter.so: filter library #2: init failure
command failed: json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail
json: error: <stdin>: filter library #1: handler failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail
/a/b=c
$

--[ fail-init ]-----------------------------------------------------------------

$ json() { json0 -F "$@"; }
$ json -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library: init failure
command failed: json -- ../lib/test-filter.so --fail=init
$ json() { json0 -f "$@" <<< '{}'; }
#
# # meta command:
# $ for i in no-fail fail=init fail=handler fail=exec; do for j in no-fail fail=init fail=handler fail=exec; do [ "$j" == "$i" ] && continue; for k in no-fail fail=init fail=handler fail=exec; do [ "$k" == "$j" ] && continue; [ "$k" == "$i" ] && continue; for l in no-fail fail=init fail=handler fail=exec; do [ "$l" == "$k" ] && continue; [ "$l" == "$j" ] && continue; [ "$l" == "$i" ] && continue; c="json -- ../lib/test-filter.so --$i -- ../lib/test-filter.so --$j -- ../lib/test-filter.so --$k -- ../lib/test-filter.so --$l"; echo "$ $c"; eval "$c" || echo "command failed: $c"; done; done; done; done
#
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec
json: error: ../lib/test-filter.so: filter library #2: init failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler
json: error: ../lib/test-filter.so: filter library #2: init failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec
json: error: ../lib/test-filter.so: filter library #3: init failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library #4: init failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler
json: error: ../lib/test-filter.so: filter library #3: init failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library #4: init failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init
$ json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec
json: error: ../lib/test-filter.so: filter library #1: init failure
command failed: json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec
$ json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler
json: error: ../lib/test-filter.so: filter library #1: init failure
command failed: json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec
json: error: ../lib/test-filter.so: filter library #1: init failure
command failed: json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec
$ json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail
json: error: ../lib/test-filter.so: filter library #1: init failure
command failed: json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail
$ json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler
json: error: ../lib/test-filter.so: filter library #1: init failure
command failed: json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail
json: error: ../lib/test-filter.so: filter library #1: init failure
command failed: json -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec
json: error: ../lib/test-filter.so: filter library #3: init failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library #4: init failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec
json: error: ../lib/test-filter.so: filter library #2: init failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail
json: error: ../lib/test-filter.so: filter library #2: init failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library #4: init failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail
json: error: ../lib/test-filter.so: filter library #3: init failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler
json: error: ../lib/test-filter.so: filter library #3: init failure
command failed: json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library #4: init failure
command failed: json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler
json: error: ../lib/test-filter.so: filter library #2: init failure
command failed: json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail
json: error: ../lib/test-filter.so: filter library #2: init failure
command failed: json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init
json: error: ../lib/test-filter.so: filter library #4: init failure
command failed: json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=init
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail
json: error: ../lib/test-filter.so: filter library #3: init failure
command failed: json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=init -- ../lib/test-filter.so --no-fail
$

--[ fail-handler ]--------------------------------------------------------------

$ json() { json0 -F "$@"; }
$ json -- ../lib/test-filter.so --fail=handler
test-filter.so: generic action
$ json() { json0 -f "$@" <<< '{}'; }
#
# # meta command:
# $ for i in no-fail fail=handler fail=exec; do for j in no-fail fail=handler fail=exec; do [ "$j" == "$i" ] && continue; for k in no-fail fail=handler fail=exec; do [ "$k" == "$j" ] && continue; [ "$k" == "$i" ] && continue; c="json -- ../lib/test-filter.so --$i -- ../lib/test-filter.so --$j -- ../lib/test-filter.so --$k"; echo "$ $c"; eval "$c" || echo "command failed: $c"; done; done; done
#
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec
json: error: <stdin>: filter library #2: handler failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler
json: error: <stdin>: filter library #3: handler failure
command failed: json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec
json: error: <stdin>: filter library #1: handler failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec
$ json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail
json: error: <stdin>: filter library #1: handler failure
command failed: json -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler
json: error: <stdin>: filter library #3: handler failure
command failed: json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=handler
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail
json: error: <stdin>: filter library #2: handler failure
command failed: json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --fail=handler -- ../lib/test-filter.so --no-fail
$

--[ fail-exec ]-----------------------------------------------------------------

$ json() { json0 -F "$@"; }
$ json -- ../lib/test-filter.so --fail=exec
json: error: ../lib/test-filter.so: filter library: exec failure
command failed: json -- ../lib/test-filter.so --fail=exec
$ json() { json0 -f "$@" <<< '{"a":{"b":"c"}}'; }
#
# # meta command:
# $ for i in no-fail fail=exec; do for j in no-fail fail=exec; do [ "$j" == "$i" ] && continue; c="json -- ../lib/test-filter.so --$i -- ../lib/test-filter.so --$j"; echo "$ $c"; eval "$c" || echo "command failed: $c"; done; done
#
$ json -- ../lib/test-filter.so --no-fail -- ../lib/test-filter.so --fail=exec
/a/b=c
$ json -- ../lib/test-filter.so --fail=exec -- ../lib/test-filter.so --no-fail
/a/b=c
$


