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

login
register
mail settings
Submitter Danek Duvall
Date March 2, 2016, 11:22 p.m.
Message ID <4a15c707703d3adaadb5.1456960942@smelly.us.oracle.com>
Download mbox | patch
Permalink /patch/13577/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Danek Duvall - March 2, 2016, 11:22 p.m.
# HG changeset patch
# User Danek Duvall <danek.duvall@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.
Katsunori FUJIWARA - March 3, 2016, 8:52 a.m.
At Wed, 02 Mar 2016 15:22:22 -0800,
danek.duvall@oracle.com wrote:
> 
> # HG changeset patch
> # User Danek Duvall <danek.duvall@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@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
Danek Duvall - March 3, 2016, 3:27 p.m.
FUJIWARA Katsunori wrote:

> 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)

Oracle Solaris doesn't use the ksh93 implementations of various core
commands like cmp; we're back to using the original Solaris implementation
as of Solaris 11 (build 169, which came after the close).

I'm happy to file a bug against cmp; it certainly seems like a message that
should be silenced by -s, but that won't help us here.

Thanks,
Danek
Katsunori FUJIWARA - March 4, 2016, 1:47 p.m.
At Thu, 3 Mar 2016 07:27:14 -0800,
Danek Duvall wrote:
> 
> FUJIWARA Katsunori wrote:
> 
> > 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)
> 
> Oracle Solaris doesn't use the ksh93 implementations of various core
> commands like cmp; we're back to using the original Solaris implementation
> as of Solaris 11 (build 169, which came after the close).

Thank you for information of Solaris11. I got Solaris11 environment,
and confirmed both the issue and effect of this patch.


> I'm happy to file a bug against cmp; it certainly seems like a message that
> should be silenced by -s, but that won't help us here.
> 
> Thanks,
> Danek
> 

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

Patch

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)