Bash throwing “ignored null byte in input” warning in a script

bash

I have a script that runs in bash 4.3 and checks for an rpm package.
I want the same script to run successfully on bash 4.4 but the script throws a warning “warning: command substitution: ignored null byte in input”.
Below is the line that is throwing this warning:

FIND_RPM=find /opt/RPM/components -type d -name enum-1.1.6 -print0

The script is executed in debug mode as below:

 +++ find /opt/RPM/components -type d -name eum-1.1.6 -print0
bash: warning: command substitution: ignored null byte in input
++ LINSEE_RPM=/opt/RPM/components/enum-1.1.6

How should i now rewrite this line to ignore this warning and silently drop this null byte as is done in bash4.3?

Best Answer

As you are not using the \0 bytes that the option -print0 generates, you might want:

 FIND_RPM="$(find /opt/RPM/components -type d -name enum-1.1.6 -print)"
Related Question