From: Bart Schaefer <schaefer@brasslantern.com>
To: Branden Archer <brarcher@lexmark.com>, zsh-workers@zsh.org
Subject: Re: Issue with resolving paths with zsh using \0 in variables
Date: Wed, 14 Jun 2017 16:02:24 -0700 [thread overview]
Message-ID: <170614160224.ZM20305@torch.brasslantern.com> (raw)
In-Reply-To: <CAADoZg3dsdn6yBrkUYQj3=w6ZKyqQDu5sG+kEas9c5yLNU1XPA@mail.gmail.com>
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.
next prev parent reply other threads:[~2017-06-14 23:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 19:32 Branden Archer
2017-06-14 0:38 ` Eric Cook
2017-06-14 23:02 ` Bart Schaefer [this message]
2017-06-15 3:40 ` Eric Cook
2017-06-15 4:13 ` Bart Schaefer
2017-06-15 4:22 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=170614160224.ZM20305@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=brarcher@lexmark.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).