Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kazuho
Copy link
Contributor

@kazuho kazuho commented Nov 16, 2018

As discussed in README.md, comparing two qifs hasn't been an easy task. This PR solves the issue by adding --diff option to sort-qif.pl.

Now, instead of doing something like:

diff <(sort-qif.pl --strip-comments a.qif) <(sort-qif.pl --strip-comments b.qif)

you can simply do:

sort-qif.pl --diff --strip-comments a.qif b.qif

It can also be used to pass other flags that affect the sorting logic (i.e. sort-qif.pl --diff --http a.qif b.qif can be used for comparing the output of h2o).

@kazuho
Copy link
Contributor Author

kazuho commented Nov 16, 2018

@dtikhonov I was considering how to help others trying to compare the QIF files generated from the output of H2O, and noticed that adding --diff option to sort-qif.pl might be a win for all of us. WDYT?

@kazuho kazuho requested a review from dtikhonov November 16, 2018 06:24
@dtikhonov
Copy link
Member

I think that in this case, worse is better (after all, I do live in New Jersey). Placing the logic in the program hides how the comparison works. People not familiar with Perl -- alas! those are in the violently loud and proud majority now -- will be lost.

In other words, I do not agree with the premise; comparing QIF files is not difficult.

A different problem is the --diff argument itself: is the program supposed to sort or to diff? The UNIX philosophy is to do one thing and do it well. Perhaps make a different program named diff-qifs.pl?

Nevertheless, so long as the sorting behavior of sort-qifs.pl remains unchanged, I am not against you adding another option to it. I would like, however, to keep the current diffing instructions in the README; the "easier" way to diff should be listed as an alternative.

@dtikhonov
Copy link
Member

Oh, and the diff mode won't work on systems without /dev/fd/fileno.

@kazuho
Copy link
Contributor Author

kazuho commented Nov 17, 2018

@dtikhonov Thank you for your comments.

I will change the approach to creating a script file dedicated to taking the diff.

The question is if we can assume that the diff script will exist next to sort-qifs.pl in the same directory, but I think we can assume that. Then, it becomes simply a matter of doing pathname($0) . "/sort-qifs.pl" in the diff script.

Oh, and the diff mode won't work on systems without /dev/fd/fileno.

Yeah I can change the exec arguments to bash -c exec diff /dev/fd/x /dev/fd/y, so that bash's emulation of /dev/fd will kick in on systems without /dev/fd. Then, it would work on any system with bash being installed.

IIUC, current recommendation of using <(...) requires the running shell to be bash. Changing the requirement to "either bash is installed or /dev/fd is available" will be an improvement :-)

@dtikhonov
Copy link
Member

We can make the README more portable by using temporary files.

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