Skip to content

don't sort keys #11

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

Closed
wants to merge 1 commit into from
Closed

Conversation

perlpunk
Copy link
Contributor

@perlpunk perlpunk commented Apr 1, 2016

I think it's not necessary to sort the keys.
Also then there's no need for a special case for osx test here any more

no need for a special case for osx test here any more
@@ -75,7 +75,7 @@ JSON.keys() {
JSON.object "$@" |
cut -f1 |
sed "s/^\///; s/\/.*//" |
sort -u
uniq

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having just uniq here makes it look like it is assumed that the keys are already sorted. Because uniq only removes same values on adjacent lines. It would actually make more sense to either keep the sort -u, or drop it completely and just assume the user knows what he's doing. Since JSON is position independent, I'd vote to keep the sort -u in place and make it easier for the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dolik-rce good point. There might be situations (depending on how put would be implemented, for example) where they keys are not on adjacent lines.
I guess that why I'd put in the sort in the first place ;-)

@dolik-rce
Copy link

I think it would be better to fix the test. Since the difference on OS X is probably due to different locale setting, the simplest way to correct the test would be to make sure same locale is used. I'd just change the expected value to expect="$(sort <<< "file1.txt"$'\n'"file 2.txt")". Unfortunately, I'm not a mac owner, so I can't test right now, but it should fix the problem and remove the need for special case.

@perlpunk
Copy link
Contributor Author

perlpunk commented Apr 4, 2016

@dolik-rce thanks, good idea!

@perlpunk
Copy link
Contributor Author

perlpunk commented Apr 5, 2016

Created a new PR with the suggestion from @dolik-rce

@perlpunk perlpunk closed this Apr 5, 2016
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

Successfully merging this pull request may close these issues.

2 participants