zephyrproject-rtos / west

West, Zephyr's meta-tool
https://docs.zephyrproject.org/latest/guides/west/index.html
Apache License 2.0
231 stars 122 forks source link

grep: fix command hanging forever when grep.{tool}-args is empty #681

Closed marc-hb closed 1 year ago

marc-hb commented 1 year ago

Fixes commit 1d220bbd627b ("commands: add grep") / #678

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

marc-hb commented 1 year ago

Because I have no grep.{tool}-args configuration, west grep was ALWAYS hanging for me! So I really wondered how the test was passing.

Mystery solved: that's because the (complex) tox+pytest test environment closes the standard input.

In fact a workaround for this bug is to hit Ctrl-D repeatedly; once for each git repo.

I can see that the test environment solves a lot of problems. But it also creates some distance and divergence with the real thing. I just tried to document this gap here: