Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
binwalk
Commits
3969222a
Commit
3969222a
authored
11 years ago
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed argv parsing bug
parent
2298894b
fix-entropy-graph-legend
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
module.py
src/binwalk/module.py
+8
-4
No files found.
src/binwalk/module.py
View file @
3969222a
...
...
@@ -464,6 +464,9 @@ class Modules(object):
return
kwargs
def
_is_file
(
self
,
fname
):
return
(
not
fname
.
startswith
(
'-'
))
and
(
os
.
path
.
exists
(
fname
)
or
fname
.
startswith
(
'./'
)
or
fname
.
startswith
(
'/'
))
def
argv
(
self
,
module
,
argv
=
sys
.
argv
[
1
:]):
'''
Processes argv for any options specific to the specified module.
...
...
@@ -479,6 +482,8 @@ class Modules(object):
shorts
=
""
parser
=
argparse
.
ArgumentParser
(
add_help
=
False
)
# TODO: Add all arguments for all modules to parser so that the only unknowns will be file names.
# Only return arguments for the specified module though.
if
hasattr
(
module
,
"CLI"
):
for
module_option
in
module
.
CLI
:
...
...
@@ -491,11 +496,10 @@ class Modules(object):
action
=
None
if
module_option
.
short
:
parser
.
add_argument
(
'-'
+
module_option
.
short
,
'--'
+
module_option
.
long
,
nargs
=
module_option
.
nargs
,
action
=
action
,
dest
=
module_option
.
long
)
parser
.
add_argument
(
'-'
+
module_option
.
short
,
'--'
+
module_option
.
long
,
action
=
action
,
dest
=
module_option
.
long
)
else
:
parser
.
add_argument
(
'--'
+
module_option
.
long
,
nargs
=
module_option
.
nargs
,
action
=
action
,
dest
=
module_option
.
long
)
parser
.
add_argument
(
'--'
+
module_option
.
long
,
action
=
action
,
dest
=
module_option
.
long
)
print
argv
args
,
unknown
=
parser
.
parse_known_args
(
argv
)
args
=
args
.
__dict__
...
...
@@ -506,7 +510,7 @@ class Modules(object):
for
k
in
get_keys
(
module_option
.
kwargs
):
kwargs
[
k
]
=
[]
for
unk
in
unknown
:
if
not
unk
.
startswith
(
'-'
):
if
self
.
_is_file
(
unk
):
kwargs
[
k
]
.
append
(
unk
)
elif
has_key
(
args
,
module_option
.
long
)
and
args
[
module_option
.
long
]
not
in
[
None
,
False
]:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment