From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: vared/zle silently discards non-utf8 bytes
Date: Wed, 23 Dec 2009 11:44:51 +0100 [thread overview]
Message-ID: <237967ef0912230244i2ea13dfav734535262871db7e@mail.gmail.com> (raw)
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
next reply other threads:[~2009-12-23 10:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-23 10:44 Mikael Magnusson [this message]
2010-01-06 11:37 ` Peter Stephenson
2010-01-06 11:42 ` Peter Stephenson
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=237967ef0912230244i2ea13dfav734535262871db7e@mail.gmail.com \
--to=mikachu@gmail.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).