Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Issue with resolving paths with zsh using \0 in variables
- X-seq: zsh-workers 41285
- From: Branden Archer <brarcher@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Issue with resolving paths with zsh using \0 in variables
- Date: Tue, 13 Jun 2017 15:32:56 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lexmark-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=xg4IMrDoOXT5LE96kn36zIFtiGiSFOM0bzQYOokjLAk=; b=Ep/h+BRemMXcu9r4j+LnwNbyXabsaPws+hPerOGGsamq3X2tDG2bqghF9BI5oAnLZX uIF4gCVMG148Mvc3xJEEg7Z82ff16WB8f0i9vhIhIPMUzRyZmc2Pg40R9T+QvS+DJBrd HtErTxXYFq6sJWQZdq2m8i4MKoGh1M4exNaB8JytSEGWT/FAvao3GmP9/ZlCcTqK0OtM SRuQumc2UC+uR8IaRc529KBVdgRVbdKHx3FgTw6d90oLE8OfgfsvOGVXwFQVu/TmBEY/ 5ADWpRIDJXVAW81z0TFhhhnlUmkwn0y8BWw4WGOWPkfHrVG9731VTANFMEUsgiEaJfu+ Iybg==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author