fix(completion): handle NUL-separated package candidates - #1553
Conversation
`paru -Pc` may emit NUL-separated completion candidates. Passing that output directly through Bash command substitution makes Bash drop the NUL bytes and print: bash: warning: command substitution: ignored null byte in input Convert NUL bytes to newlines before passing the output to `_arch_compgen` so package completion keeps candidate separation without triggering the warning.
|
I can't reproduce the issue you're trying to fix with this PR |
|
I think this may depend on whether On my machine, _arch_compgen "$(paru -Pc)"and $ paru -Pc | LC_ALL=C tr -cd '\000' | wc -c
1734Bash command substitution cannot preserve NUL bytes, so Bash drops them and prints: Could you check whether paru -Pc | LC_ALL=C tr -cd '\000' | wc -cIf this returns This patch is mostly a defensive normalization rather than a behavior change. For systems where The patch changes the input passed to _arch_compgen "$(paru -Pc)"to: _arch_compgen "$(paru -Pc | tr '\000' '\n')"TL;DRThis is not intended to change completion behavior for systems that already work. It only normalizes NUL-separated output before Bash command substitution, because Bash cannot preserve NUL bytes anyway. |
|
my guess is that your |
|
I am getting the same warning as @Scott-Nx. |
Fix Bash completion warning caused by NUL-separated package candidates from
paru -Pc.Problem
When completing package names with Bash completion, for example:
Bash prints:
The warning comes from
_paru_pkg():_arch_compgen "$(paru -Pc)"paru -Pcemits NUL bytes. Bash command substitution cannot preserve NUL bytes, so Bash drops them and prints the warning.On my system:
Fix
Convert NUL bytes to newlines before passing the output into
_arch_compgen:_arch_compgen "$(paru -Pc | tr '\000' '\n')"This preserves candidate separation and avoids the Bash warning.
Testing
Confirmed that
paru -Pcemits NUL bytes:Confirmed that converting NUL bytes to newlines removes them:
After applying the patch, Bash completion works without the warning:
Expected candidates are shown: