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

Not able to run diff2html-cli on both windows and wsl #161

Open
sahithnani opened this issue Aug 13, 2023 · 4 comments
Open

Not able to run diff2html-cli on both windows and wsl #161

sahithnani opened this issue Aug 13, 2023 · 4 comments

Comments

@sahithnani
Copy link

Hi Recently i've updated DIff2html-cli on my machine. This is the command i've used "diff2html -s side -F output.html -- file1.txt file2.txt" But all i'm getting is unknown arguments file1.txt, file2.txt. Can anyone help me with this.
And also somehow its working on my friends machine. But he is using this flad "--renderNothingWhenEmpty". Here's the command he used "diff2html -s side --renderNothingWhenEmpty -F output.html -- file1.txt file2.txt". But for him the html report is getting generated even when there are no differences.
image

I used a windows 10 machine and we have wsl installed with ubuntu 20.04. the machine is a dell precision5560.

@rtfpessoa
Copy link
Owner

What are you expecting that command to do?

@ArthurAttout
Copy link

@rtfpessoa for some reason I could never figure out, diff2html simply does not work under Powershell.

No matter what I try, it will always return the help menu, with only one reason

Unknown argument: diff.diff

For example the command diff2html -i file -- diff.diff work like a charm under git bash, but Powershell will simply not cooperate.

I suspect it has to do with arguments after -- not playing well with Powershell, but I never had the time to dive deeper in this.

@rtfpessoa
Copy link
Owner

I don't have a windows computer to test atm so I is a bit hard to validade without more information

@ArthurAttout
Copy link

ArthurAttout commented Sep 5, 2023

Okay, I took a look at it, and it's because Powershell will drop double hyphens --, see this post

A double hyphen instructs PowerShell to treat everything coming after as literal arguments rather than options, so that you can pass for instance a literal -foo to your script/application/cmdlet.

diff2html will never see -- in argv so the last parameter is ambiguous.

Value of argv under git bash :

$ diff2html -i file -- patch.diff
[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\diff2html-cli\\bin\\d
iff2html.js',
  '-i',
  'file',
  '--',
  'patch.diff'
]

Value of argv under Powershell :

C:\Users\me\source\repos\test> diff2html -i file -- patch.diff
[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\diff2html-cli\\bin\\diff2html.js',
  '-i',
  'file',
  'patch.diff'
]

For the command to work under Powershell, the user needs to escape the double hyphens

diff2html -i file `-- diff.diff

or

diff2html -i file "--" diff.diff

It's ugly and there's basically nothing diff2html can do about it. But it could be worth an addition to the README, because most Powershell syntax never uses double hyphens, and users are little-aware about this.

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

3 participants