Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] history corrupt on utf8
- X-seq: zsh-workers 31492
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: [bug] history corrupt on utf8
- Date: Sun, 23 Jun 2013 23:24:04 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=CxwsS7QR+9tq34S22zpQjBPYUt2gtOt4vHboqDx37tM=; b=p5V8E5SZ8oX58SsRQqRUrLXSAB6elZrWX7Je6Yi+o9cZVLbPbOdZypYMJlYFYaqC3K Wl701xQqCZr08LdXX6YVRsqpM5o7GKgskSOm6L/snzM1rbkkbr/KOZ81+9ePY8bCt7B3 6yAaNqtD90luIDT136awLRgTCK99yk8CyX2Qlm2kzy31ixd8HZmWVHhmw6P8CkLlogZN DDSB8lXivRw6dRBwVjBsxdMnHYwqsM9ZDfEDj/7Befj2TNxe1jBPh+tVlJygMr2ykjUI NsFnZ6RMxDrC7pz0CxBVX0UtNXTE17yCkC75v+cAMVsRoGRYgDFgVL3CdclzHloFuIxH RmxQ==
- In-reply-to: <CAH+w=7ZQiT8g3uU+rzmKNWC+WE-xOrVCX_LUHZKJq5tPnOxgtw@mail.gmail.com>
- 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
- References: <20130622184554.GA32128@adz-acer> <CAHYJk3RqD-JfWKUeG08Atrbhcoz9XZEXvBP_b_cP21EMy5RunA@mail.gmail.com> <CAH+w=7ZQiT8g3uU+rzmKNWC+WE-xOrVCX_LUHZKJq5tPnOxgtw@mail.gmail.com>
On 23 June 2013 20:33, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jun 22, 2013 7:07 PM, "Mikael Magnusson" <mikachu@xxxxxxxxx> wrote:
>>
>> The history file isn't saved verbatim, since the command line can
>> contain non-utf8, nuls, etc.
>
> To be more specific, the history file is saved in the same format used to
> represent history lines internally, except for prefixing newlines with
> backslash. The file is only "corrupted" if zsh itself can't re-read it.
> We gave up on sharing history files with other shells a long time ago.
If you want, you can use this small program to "uncorrupt" it
(obviously don't overwrite the history file with the result),
#define Meta ((char) 0x83)
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
/* from zsh utils.c */
char *unmetafy(char *s, int *len)
{
char *p, *t;
for (p = s; *p && *p != Meta; p++);
for (t = p; (*t = *p++);)
if (*t++ == Meta)
t[-1] = *p++ ^ 32;
if (len)
*len = t - s;
return s;
}
int main(int argc, char *argv[]) {
char *line = NULL;
size_t size;
while (getline(&line, &size, stdin) != -1) {
unmetafy(line, NULL);
printf("%s", line);
}
if (line) free(line);
return EXIT_SUCCESS;
}
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author