zsh-workers
 help / color / mirror / code / Atom feed
* Issue with resolving paths with zsh using \0 in variables
@ 2017-06-13 19:32 Branden Archer
  2017-06-14  0:38 ` Eric Cook
  2017-06-14 23:02 ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Branden Archer @ 2017-06-13 19:32 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]

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.

There is a workaround for this, which is to use realpath on the directory
then use the result to access the file:


root~# complete=$(realpath sub$(cat location))
realpath: : No such file or directory
# ^ from stderr
root~# echo "hi" > ${complete}/myfile


However, it would be nicer if that workaround was not necessary.

If you have any questions about this issue, let me know. Thanks!

- Branden

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-06-15  4:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-13 19:32 Issue with resolving paths with zsh using \0 in variables Branden Archer
2017-06-14  0:38 ` Eric Cook
2017-06-14 23:02 ` Bart Schaefer
2017-06-15  3:40   ` Eric Cook
2017-06-15  4:13     ` Bart Schaefer
2017-06-15  4:22     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).