Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
vared/zle silently discards non-utf8 bytes
- X-seq: zsh-workers 27539
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: vared/zle silently discards non-utf8 bytes
- Date: Wed, 23 Dec 2009 11:44:51 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=L0DH1VwVeiTioIElnynHAzYz3fB6ckDeCzOoIJzWRk4=; b=l8PTugWaVW+VoYKNaCuZe1RuX2TpWBXYj044TlvRVaaS7k9miXzglSsI38oCUKCxqf aw0iXf8GKcQPUw+ssfI/D7LbljaXhus1FwUDWGOgTgUedVJH1MpiiDm/wXr1rkEEWdWR 3sHOttT9/bUrqU1jeum6VaZqbTntiwBp7Wvl8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=pWzxgUUDvCXhH1Wof9bcFFYq+bPlVqjxTgMs96o+GSDT1Y9vaYYHAjILyURlNjGqto StuhGSCUJEZj1GHFbHDWUPUD8vpvClyuv+pYtdPG0mlAZQd81kiYX+0JbWTOAD9ek1J8 YFNyG2F1o6sewmtnEdGZxyrTxIRoBm97cfv3s=
- 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
I have this function
function name() {
[[ $#@ -eq 1 ]] || { echo Give exactly one argument ; return 1 }
test -e "$1" || { echo No such file or directory: "$1" ; return 1 }
local newname=$1
if vared -c -p 'rename to: ' newname &&
[[ -n $newname && $newname != $1 ]]
then
command mv -i -- $1 $newname
else
echo Some error occured; return 1
fi
}
which I use to rename files interactively if they just need small
adjustments. It would also be useful for files in wrong encodings
where there's a à here or there. Unfortunately it seems vared discards
anything after an invalid byte. To reproduce, just do
% a=hi$'\374'nothing
% vared a
It actually seems main zle does this too (I thought it would do the
<0374> thing, but then realized those are unicode code points so that
wouldn't work), but it's much harder to hit since completion inserts
the $'\374' sequence for you and there's really no simple way to
insert the string. If you start a terminal in latin1 and run a command
with some upper byte, then press up-arrow in a utf8 terminal,
everything after that byte is silently discarded too. I care less
about this case personally.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author