Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: cmp(1) as a builtin



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.



Messages sorted by: Reverse Date, Date, Thread, Author