I\'m getting -bash: warning: command substitution: ignored null byte in input when I run model=$(cat /proc/device-tree/model)
bash
There are two possible behaviors you might want here:
Read until first NUL. This is the more performant approach, as it requires no external processes to the shell. Checking whether the destination variable is non-empty after a failure ensures a successful exit status in the case where content is read but no NUL exists in input (which would otherwise result in a nonzero exit status).
IFS= read -r -d '' model Read ignoring all NULs. This gets you equivalent behavior to the newer (4.4) release of bash.
model=$(tr -d '\0'
You could also implement it using only builtins as follows:
model=""
while IFS= read -r -d '' substring || [[ $substring ]]; do
model+="$substring"
done