Skip to content

Commit

Permalink
grep: fix command hanging forever when grep.{tool}-args is empty
Browse files Browse the repository at this point in the history
Fixes commit 1d220bb ("commands: add grep")

Fix misplaced closing parenthese in:

```
shlex.split(self.config.get(f'grep.{tool}-args'), '')
```

The empty string is meant as a default value for config.get() but it was
passed as a second argument to shlex.split() by mistake.

Funny enough this hangs forever:

```
>>> shlex.split(None, comments='')
<stdin>:1: DeprecationWarning: Passing None for 's' to shlex.split() is deprecated.
 (hangs forever)
```

PS: debuggers rulez

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb authored and mbolivar-ampere committed Aug 31, 2023
1 parent 4ba3d99 commit 3e53dd5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ def tool_args(self, tool, cmdline_args):
color = 'never'

ret.extend([f'--color={color}'])
ret.extend(shlex.split(self.config.get(f'grep.{tool}-args'), '') or
ret.extend(shlex.split(self.config.get(f'grep.{tool}-args', '')) or
self.DEFAULT_TOOL_ARGS[tool])

# The first '--' we see is "meant for" west grep. Take that
Expand Down

0 comments on commit 3e53dd5

Please sign in to comment.