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
--argfile behavior #705
Comments
Yes, it does this: slurp the file, and if the thing is an array of just one element, it uses that, else it uses the slurped array. That's lame, I agree (yes, I wrote that code :). I'll make it just slurp. |
I wouldn't be against |
Hmmm, this is a backwards-incompatible change. |
I may have to revert this change. |
@nicowilliams wrote:
(1) The current behavior is inconsistent with the manual, so there is quite a lot of wriggle room here. Since (2) The current specification of --argfile (if the manual can be read as a specification) has the advantage that it complements --slurpfile. The more orthogonality, the better. (3) Please do not read (2) as a strong endorsement of the documented behavior: see (1). (4) Having control on a file-by-file basis would be a Very Good Thing. |
The way to distinguish what happened (slurped vs. not slurped) could be to add a second variable named after the given one. |
I'll probably do that and revert the change I pushed earlier. |
I think I'll restore the original behavior and add a new argument with better behavior. |
The manual says:
This however is inconsistent with the current behavior, which is (in a sense) itself inconsistent. If file
a
contains a string, thenjq -n --argfile a a '$a'
prints it out; but if it contains two strings, or is empty, the same program prints an array.The current behavior is certainly justifiable, but maybe this is a good time to orthogonalize things a bit -- perhaps even to the point of giving the user the same control over each "argfile" as is afforded with respect to stdin. For example, we could have --argfile, --argfile-slurp, argfile-raw, ...
Food for thought? (No slurping, please.)
The text was updated successfully, but these errors were encountered: