Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Doc errors / improvements #1658

Open
balki opened this issue Sep 22, 2024 · 2 comments
Open

[Doc] Doc errors / improvements #1658

balki opened this issue Sep 22, 2024 · 2 comments

Comments

@balki
Copy link
Contributor

balki commented Sep 22, 2024

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} )'

@balki
Copy link
Contributor Author

balki commented Sep 22, 2024

Unrelated: When can we expect a new release next?

@johnkerl
Copy link
Owner

Thanks for the finds @balki ! :)

The next release I can do after I finish #1621

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants