Skip to content

Fix -y/-x consuming the target file name - #980

Open
blaze0089 wants to merge 1 commit into
ReFirmLabs:masterfrom
blaze0089:fix/include-exclude-args
Open

blaze0089 wants to merge 1 commit into
ReFirmLabs:masterfrom
blaze0089:fix/include-exclude-args

Conversation

@blaze0089

Copy link
Copy Markdown

Fixes #976.

-y and -x are declared with num_args = 1.., which makes clap treat every following value as another signature. binwalk -y zip firmware.bin parses firmware.bin as a second include value, leaves file_name empty, and produces "No target file name specified". The --include=zip form works because the value is attached to the option.

Removing num_args leaves the default of one value per occurrence. Comma-separated lists (-y zip,png) and repeated flags still work, and the positional file name is no longer swallowed.

Added parser tests in src/cliparser.rs for -y zip firmware.bin, -y zip,png firmware.bin, -x zip firmware.bin, and --include=zip firmware.bin.

Verified with cargo test --bin binwalk (4 passed), cargo fmt --check, and the built binary:

$ binwalk -y zip missing.bin
Failed to open file ...\missing.bin: The system cannot find the file specified.
Analyzed 1 file for 1 file signatures (1 magic patterns)

@blaze0089
blaze0089 force-pushed the fix/include-exclude-args branch from d607ff1 to 4cdd68b Compare November 8, 2026 04:03
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.

Error parsing -y parameter

1 participant