Skip to content

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

Description

@sahithnani

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.

Activity

  1. rtfpessoa commented on Aug 25, 2023

    @rtfpessoa
    Owner

    What are you expecting that command to do?

  2. ArthurAttout commented on Sep 1, 2023

    @ArthurAttout

    @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.

  3. rtfpessoa commented on Sep 1, 2023

    @rtfpessoa
    Owner

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

  4. ArthurAttout commented on Sep 5, 2023

    @ArthurAttout

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions