Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
cmp(1) as a builtin
- X-seq: zsh-users 18872
- From: Roman Neuhauser <neuhauser@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: cmp(1) as a builtin
- Date: Mon, 2 Jun 2014 18:34:46 +0200
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
hello,
i need to run cmp(1) on a heap of mostly small files, and the forking
overhead is killing me. i added a PoC bit to zsh/files to expose b:cmp
and C:qf (eQual Files). it seems to work, but i'm pretty sure it has
issues as i don't know what i'm doing here, on several levels.
questions:
the cmp builtin currently always reads the file data. it should stat
both operands to see if that can be skipped. what api do i use for
that? does zsh have some kind of stat cache i should hook into?
if either operand is "-", it should read from stdin. how do i get hold
of standard input in the builtin? can i use the standard FILE* handle
(stdin), do i need fdopen(SHIN, "r") (or use SHIN directly), or...?
the condexpr operator ([[ x -qf y ]]) is implemented like this:
static int
cond_cmp(char **args, UNUSED(int func))
{
return 0 == do_cmp(
"cond_qf", 1,
cond_str(args, 0, 0),
cond_str(args, 1, 0)
);
}
do_cmp() passes the cond_str() results to fopen(). am i using
cond_str() correctly?
--
roman
Messages sorted by:
Reverse Date,
Date,
Thread,
Author