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

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



On 06/13/2017 03:32 PM, 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. Here is an example of this:
> 
> 
> root~# echo $ZSH_VERSION
> 5.3.1
> root~# mkdir subdir
> root~#
> root~# printf "dir\0" > location
> root~# touch subdir/myfile
> root~# echo "hi" > sub$(cat location)/myfile
> zsh: is a directory: subdir
> root~# echo "hi" > subdir/myfile
> 
> 
> It was found on bash that this did work, so it is believed that this is a
> valid use case. Namely, on bash the \0 at the end of the data returned
> from $(cat
> location) is ignored.


Silently mangling input isn't a valid usecase, even recently in
bash there is an warning that is displayed when it happens.

http://lists.gnu.org/archive/html/bug-bash/2017-04/msg00016.html



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