This IMO is a subtle bug which may be an off by one error somewhere in the generated output string buffer index.
In general if you use Bash to capture the output of the /proc/acpi/nuc_led to later process it like this:
nuc_led_output="$(cat /proc/acpi/nuc_led)"
Then you get a warning along the lines of:
Bash: warning: command substitution: ignored null byte in input
This is because you are adding the null byte ('\0') into the middle of the Bash string which internally is also a C string, so it ignores it.
This leads me to believe that the function that is creating the string buffer is either printing one character past the end of the actual buffer and overflowing it (causing the null character to be printed) or its being purposely injected/included in the output string. It would be better for the null byte not to be included in the output.
As a workaround, I have just been translating away the null byte:
nuc_led_output="$(cat /proc/acpi/nuc_led | tr "\0" "\n")"
This IMO is a subtle bug which may be an off by one error somewhere in the generated output string buffer index.
In general if you use Bash to capture the output of the
/proc/acpi/nuc_ledto later process it like this:Then you get a warning along the lines of:
This is because you are adding the null byte ('\0') into the middle of the Bash string which internally is also a C string, so it ignores it.
This leads me to believe that the function that is creating the string buffer is either printing one character past the end of the actual buffer and overflowing it (causing the null character to be printed) or its being purposely injected/included in the output string. It would be better for the null byte not to be included in the output.
As a workaround, I have just been translating away the null byte: