Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Issue with resolving paths with zsh using \0 in variables



On Jun 13,  3:32pm, Branden Archer wrote:
}
} This is an issue found when attempting to use paths in zsh where
} parts of the path are taken from data on the /sys filesystem. Namely,
} when cat'ing a file from the /sys filesystem it may return some data
} with a \0 at the end. If that variable is used to form a path the \0
} interferes with the path resolution.

I believe this is because zsh supports having nul-bytes in parameter
values, whereas bash treats the nul as terminating the string.  This
is not something we can (or I think want) to special-case for file
paths.

Those files in /sys are documented to contain strings separated by
nul bytes, so as soon as you read one with "cat" you have already
made a coding error.  Instead you should be doing something like

    read -d $'\0' -E < location

Conversely, this --

} root~# echo "hi" > sub$(cat location)/myfile
} zsh: is a directory: subdir

-- probably is a bug, just not the bug you think it is; the error should
be that "subdir\0" is an illegal file name, rather than terminating the
path at the nul and botching the redirection.



Messages sorted by: Reverse Date, Date, Thread, Author