zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: cmp(1) as a builtin
Date: Mon, 02 Jun 2014 21:28:10 -0700	[thread overview]
Message-ID: <140602212810.ZM26999@torch.brasslantern.com> (raw)
In-Reply-To: <20140602163446.GB1629@isis.sigpipe.cz>

On Jun 2,  6:34pm, Roman Neuhauser wrote:
}
} 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?

Zsh does not have any special API or cache for stat data.  The closest
thing is cond.c:getstat() which has some special handling for /dev/fd/
files, but is currently declared static.

} 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...?

You can use stdin.  SHIN is the command input stream (e.g., terminal or
script file), so don't use that.

} do_cmp() passes the cond_str() results to fopen().  am i using
} cond_str() correctly?

I believe so, yes.  Compare to Src/Modules/example.c cond_i_ex().

You may want to put these in your own module rather than modifying the
zsh/files module. Editing copies of Src/Modules/example.* works well
for this.


      reply	other threads:[~2014-06-03  4:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-02 16:34 Roman Neuhauser
2014-06-03  4:28 ` Bart Schaefer [this message]

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=140602212810.ZM26999@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).