[PATCH 3 of 4] tests: Solaris cmp complains about empty files, even with -s

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Mar 3 03:52:33 EST 2016


At Wed, 02 Mar 2016 15:22:22 -0800,
danek.duvall at oracle.com wrote:
> 
> # HG changeset patch
> # User Danek Duvall <danek.duvall at oracle.com>
> # Date 1456959509 28800
> #      Wed Mar 02 14:58:29 2016 -0800
> # Node ID 4a15c707703d3adaadb595c96dc07638e6a746e8
> # Parent  06f40ce66d200ab9869e2d70bfa127582c6ea26d
> tests: Solaris cmp complains about empty files, even with -s
> 
> When you compare an empty file, such as /dev/null, with a non-empty file,
> Solaris cmp complains on stderr with "cmp: EOF on /dev/null", even if the
> -s argument is present.  GNU cmp makes the complaint, but silences it with
> -s.  We can change the pdiff utility to simply redirect stderr to /dev/null
> so that we don't have to worry about this difference in the test files.

AFAIK, /bin/cmp (/usr/bin/cmp shares same inode with it) on Solaris
stops showing "cmp: EOF on foobar" if -s is specified.

At least, cmp on OI 151a2 (a little old, though) below does so. What
version of cmp is used on your environment ?

    $ /bin/cmp --version
    version         cmp (AT&T Research) 2009-01-05


FYI, according to source tree of (Open)Solaris, system default cmp
command consists of files below, and all "cmp: EOF on %s" output in
the latter file is always suppressed by -s (CMP_SILENT).

  - main() to dispatch to some basic commands:
    https://bitbucket.org/illumos/illumos-gate/src/tip/usr/src/cmd/ksh/builtins/alias.c

  - core logic of cmp:
    https://bitbucket.org/illumos/illumos-gate/src/tip/usr/src/lib/libcmd/common/cmp.c

(or https://github.com/illumos/illumos-gate)

> diff --git a/tests/pdiff b/tests/pdiff
> --- a/tests/pdiff
> +++ b/tests/pdiff
> @@ -25,7 +25,7 @@ filediff(){
>          file2=/dev/null
>      fi
>  
> -    if cmp -s "$file1" "$file2"; then
> +    if cmp -s "$file1" "$file2" 2> /dev/null; then
>          # Return immediately, because comparison isn't needed. This
>          # also avoids redundant message of diff like "No differences
>          # encountered" (on Solaris)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list