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

Fix for issue 1876 - Updated the batch file to replace "%" in arguments with an arbitrary … #2310

Conversation

Duncan-Howe
Copy link
Contributor

@Duncan-Howe Duncan-Howe commented Nov 1, 2020

…placeholder "##PC##" during the "collectargs" routine and then restoring the "%" signs prior to passing to the scancode executable

Signed-off-by: Duncan Howe [email protected]

Fixes #1876

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁

…placeholder "##PC##" during the "collectargs" routine and then restoring the "%" signs prior to passing to the scancode executable

Signed-off-by: Duncan Howe <[email protected]>
@sschuberth
Copy link
Collaborator

Hmm, maybe before trying to fix the logic to "collect all command line arguments in a variable" we should ask @pombredanne why this collecting is even necessary. More concretely, why don't we just use %* instead of creating SCANCODE_CMD_LINE_ARGS?

@pombredanne
Copy link
Member

@Duncan-Howe Thank you ++
I wonder how to add a test for this?
@sschuberth I am no expert in batch files and cmd: this was to "slurp" arguments is as old as scancode itself.
If I recall correctly this is an idiom that I first saw in Tomcat https://github.com/apache/tomcat80/blob/trunk/bin/startup.bat#L47
I am fine with replacing this with anything that works nicely everywhere :)

@pombredanne
Copy link
Member

For reference #1876

@pombredanne
Copy link
Member

@Duncan-Howe Do you mind to also update the changelog?

@Duncan-Howe
Copy link
Contributor Author

@pombredanne What version number should I use as the heading for CHANGELOG or would vNext be OK?

@sschuberth
Copy link
Collaborator

I am no expert in batch files and cmd: this was to "slurp" arguments is as old as scancode itself.

If the aim is to forward all args passed to the batch file, then IMO %* could be used and no complicated replacement of placeholders should be necessary. The story becomes more complicated if you want to forward e.g. all but the first argument, but this is not the case here AFAIU the code. BTW, the Tomcat code says to "Get remaining unshifted command line arguments", but there actually are no unshifted arguments before that line, so also the Tomcat code could be much simpler IMO. Tomcat probably also copied this from somewhere without exactly knowning what they are doing 😉

@sschuberth
Copy link
Collaborator

So, @Duncan-Howe, would you mind giving the %* approach a try?

Added note to CHANGELOG.rst

Signed-off-by: Duncan Howe <[email protected]>
@Duncan-Howe Duncan-Howe force-pushed the issue-1876-fix-scanning-with-percent-on-Windows branch from 7a028e5 to 3864f0f Compare November 2, 2020 16:47
@Duncan-Howe
Copy link
Contributor Author

@sschuberth Sure thing - I will refactor the batch file to use "%*" to pass the arguments through

@pombredanne
Copy link
Member

@pombredanne What version number should I use as the heading for CHANGELOG or would vNext be OK?

@Duncan-Howe Yes, that would work fine 👍

…canning-with-percent-on-Windows

# Conflicts:
#	CHANGELOG.rst
@pombredanne
Copy link
Member

Tomcat probably also copied this from somewhere without exactly knowning what they are doing wink

I would call this me doing cargo culting at its best :D
This is 15 years old :P https://github.com/apache/tomcat/blob/94400a237d15768ca227dd8c0f4dd5716b48e388/bin/startup.bat#L33

…ents to simply pass "%*" into the scancode executable

Added "*.orig" to .gitignore

Signed-off-by: Duncan Howe <[email protected]>
@Duncan-Howe
Copy link
Contributor Author

Updated scancode.bat to remove a number of lines of code that weren't really doing much :-)
Now the arguments are passed straight through using the "%*" syntax so any number of arguments should work (validation of the arguments is delegated to the ScanCode executable)

@Duncan-Howe
Copy link
Contributor Author

The updated batch file seems to perform in exactly the same way as previously when executed from ORT and produces the same result files for my own application scans

@sschuberth
Copy link
Collaborator

The updated batch file seems to perform in exactly the same way as previously

Great! Thanks a lot for getting rid of this cruft in the batch file 😄

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

LGTM and merging now!
Thank you ++

@pombredanne pombredanne merged commit 23054b0 into aboutcode-org:develop Nov 21, 2020
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.

Scanning a path with "%" fails on Windows
3 participants