Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[BUG] Issue with pattern meta characters passed to :A
- X-seq: zsh-workers 42259
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [BUG] Issue with pattern meta characters passed to :A
- Date: Fri, 12 Jan 2018 15:56:38 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=LrgF8Fhhg7q24NqH/ktmosnovzNIgaI7sqQGRGpZYpc=; b=cZqWdsothscwOvA9izbRDXanonF1zkB7uF1yWdyNItomQ/DQt45tZGYLJnxNdkhjYP SkaWuS9M5LaWn6l3KJ6j4aIz+sqMmbElOqAh9krlcmC1AJXF6DHq82urq1xoEbq0Y9Ds mbCZk0IW2Ecxa2WL8viT/8+cTnF4tOswGQ8/kzwxq20d76NwMtrN3oY5qfHlpiZwHPhQ +08gv4wAwZmW/wPjBs+hOWHWtuueFj9C33/d6Tgb70mNEt+tMMhoZyY5o6DBy+6gCuMA 4tXpNfjviy1pRrF7qrtHpSNvd3Zt8LMo17j+MgcZ7rYkdwIul9UJ5AWPHFQkDYWpSWZh WJrQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hey there. I ran into the following problem today:
% print -r ${${:-a-b}:a}
/Users/dana/a-b
% print -r ${${:-a-b}:A}
/Users/dana/a?b
The ? in the second one is 0x9b (Dash).
Both chabspath() (:a) and chrealpath() (:A) receive the input as $'a\x9bb'. :a
doesn't care, because all it's doing is manipulating '.' and '/' in the string.
It is a concern for :A, though, because it has to pass the string to realpath(),
and then it has to metafy() the result. There are two related issues, then:
1. chrealpath() can't resolve paths passed into it this way if they contain
pattern meta characters (any of them, not just '-'). It calls unmetafy(), but
that doesn't help here.
2. chrealpath() metafies the result at the end, converting (e.g.) $'.../a\x9bb'
into $'.../a\x83\xbbb', which breaks the expansion even in cases where it'd
be *accidentally* correct (like the one above).
(Quoting/escaping the expansion works around these. So does assigning 'a-b' to a
variable first, as long as you don't do something like ${${~str}:A}.)
Simply having chrealpath() call untokenize() after unmetafy() fixes the above
test case, but then there's a new problem: ${:-a-b} and ${:-$'a\x9bb'} are
indistinguishable to the function and thus give the same result. This would
break resolution of multi-byte file names, as in ${${:-ツ}:A} (ツ = $'\u30c4' =
$'\xe3\x83\x84').
Not sure how to fix properly. Metafication/tokenisation stuff is still pretty
confusing to me.
dana
Messages sorted by:
Reverse Date,
Date,
Thread,
Author