[Doc] Doc errors / improvements
I have been playing with miller for few days and it is awesome. DSL is so feature rich, complete and user-friendly. Few minor issues and feedback below. Thank you!
mlr shebang example is incorrect
❯ {echo "foo,bar";echo "1,2"} | mlr --c2p cat -n
n foo bar
1 1 2
❯ cat ex.mlr
#!/usr/bin/env mlr -s
--c2p
cat -n
❯ {echo "foo,bar";echo "1,2"} | ./ex.mlr
/usr/bin/env: ‘mlr -s’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines
env does not allow extra arguments to commands.
In newer GNU versions (~ last 5 years), env -S works. But does not work with other variants like alpine env.
Possible fixes
#!/usr/bin/env -S mlr -s#!/usr/bin/mlr -s#!mlr -s
Some functions stringify inputs unexpectedly
To check if a field is one of many values, below seem to work
❯ {echo "foo,bar";echo "1,2";echo "3,4"} | mlr --c2p filter 'contains([1,2],$foo)'
foo bar
1 2
It appears as if contains also work with arrays. But it actually stringifies the first argument and can cause surprising errors like below
❯ {echo "foo,bar";echo "1,2";echo "3,4"} | mlr --c2p filter 'contains([41,42],$foo)'
foo bar
1 2
❯ {echo "foo,bar";echo "1,2";echo "3,4"} | mlr --c2p filter 'contains([1,2],"1, 2")'
foo bar
1 2
3 4
I think it is better to fail when the first argument is an array/map than stringify. Also it may be useful to provide a easy to use function or in operator for checking if a value is one of many. I can see using any is the right way but makes it complicated with higher order function.
❯ {echo "foo,bar";echo "1,2";echo "3,4"} | mlr --c2p filter 'any([1,2], func(item){return item == $foo} )'
foo bar
1 2
❯ {echo "foo,bar";echo "1,2";echo "3,4"} | mlr --c2p filter 'any([41,42], func(item){return item == $foo} )'
Unrelated: When can we expect a new release next?
Thanks for the finds @balki ! :)
The next release I can do after I finish https://github.com/johnkerl/miller/pull/1621