Print this page
8858 /usr/bin/grep doesn't support -E option
4580 /usr/bin/grep can't handle multibyte characters
8929 8868 tests are not delivered with system/test/utiltest
8860 Example in grep(1) is incorrect
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>


  10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #       Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
  24 #         All Rights Reserved
  25 
  26 
  27 #       Copyright (c) 1999, 2001 by Sun Microsystems, Inc.
  28 #       All rights reserved.
  29 
  30 #ident  "%Z%%M% %I%     %E% SMI"        /* SVr4.0 1.4   */
  31 
  32 usage="usage: diff3 file1 file2 file3"
  33 
  34 # mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp
  35 # for this process's temporary files.  We set up a trap to remove the 
  36 # directory on exit (trap 0), and also on SIGHUP, SIGINT, SIGQUIT, SIGPIPE,
  37 # and SIGTERM.
  38 
  39 mktmpdir() {
  40         tmpdir=/tmp/diff3.$$
  41         trap '/usr/bin/rm -rf $tmpdir' 0 1 2 3 13 15
  42         /usr/bin/mkdir -m 700 $tmpdir || exit 1
  43 }
  44 mktmpdir
  45 
  46 e=
  47 case $1 in
  48 -*)
  49         e=$1
  50         shift;;
  51 esac


  63 if [ -c $f1 ]
  64 then
  65         /usr/bin/cat $f1 > $tmpdir/d3c$$
  66         f1=$tmpdir/d3c$$
  67 fi
  68 if [ -c $f2 ]
  69 then
  70         /usr/bin/cat $f2 > $tmpdir/d3d$$
  71         f2=$tmpdir/d3d$$
  72 fi
  73 if [ -c $f3 ]
  74 then
  75         /usr/bin/cat $f3 > $tmpdir/d3e$$
  76         f3=$tmpdir/d3e$$
  77 fi
  78 
  79 /usr/bin/diff $f1 $f3 > $tmpdir/d3a$$ 2> $tmpdir/d3a$$.err
  80 STATUS=$?
  81 if [ $STATUS -eq 1 ]
  82 then
  83         /usr/xpg4/bin/grep -q "^[<>]" $tmpdir/d3a$$
  84         RET=$?
  85         if [ $RET -eq 1 ]
  86         then
  87                 /usr/bin/cat $tmpdir/d3a$$
  88                 exit $STATUS
  89         fi
  90 
  91         if [ $RET -gt 1 ]
  92         then
  93                 echo "diff3 failed" 1>&2
  94                 exit $STATUS
  95         fi
  96 fi
  97 
  98 if [ $STATUS -gt 1 ]
  99 then
 100         /usr/bin/cat $tmpdir/d3a$$.err
 101         exit $STATUS
 102 fi
 103 
 104 /usr/bin/diff $f2 $f3 > $tmpdir/d3b$$ 2> $tmpdir/d3b$$.err
 105 STATUS=$?
 106 if [ $STATUS -eq 1 ]
 107 then
 108         /usr/xpg4/bin/grep -q "^[<>]" $tmpdir/d3b$$
 109         RET=$?
 110         if [ $RET -eq 1 ]
 111         then
 112                 /usr/bin/cat $tmpdir/d3b$$
 113                 exit $STATUS
 114         fi
 115 
 116         if [ $RET -gt 1 ]
 117         then
 118                 echo "diff3 failed" 1>&2
 119                 exit $STATUS
 120         fi
 121 fi
 122 
 123 if [ $STATUS -gt 1 ]
 124 then
 125         /usr/bin/cat $tmpdir/d3b$$.err
 126         exit $STATUS
 127 fi
 128 


  10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #       Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
  24 #         All Rights Reserved
  25 
  26 
  27 #       Copyright (c) 1999, 2001 by Sun Microsystems, Inc.
  28 #       All rights reserved.
  29 


  30 usage="usage: diff3 file1 file2 file3"
  31 
  32 # mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp
  33 # for this process's temporary files.  We set up a trap to remove the 
  34 # directory on exit (trap 0), and also on SIGHUP, SIGINT, SIGQUIT, SIGPIPE,
  35 # and SIGTERM.
  36 
  37 mktmpdir() {
  38         tmpdir=/tmp/diff3.$$
  39         trap '/usr/bin/rm -rf $tmpdir' 0 1 2 3 13 15
  40         /usr/bin/mkdir -m 700 $tmpdir || exit 1
  41 }
  42 mktmpdir
  43 
  44 e=
  45 case $1 in
  46 -*)
  47         e=$1
  48         shift;;
  49 esac


  61 if [ -c $f1 ]
  62 then
  63         /usr/bin/cat $f1 > $tmpdir/d3c$$
  64         f1=$tmpdir/d3c$$
  65 fi
  66 if [ -c $f2 ]
  67 then
  68         /usr/bin/cat $f2 > $tmpdir/d3d$$
  69         f2=$tmpdir/d3d$$
  70 fi
  71 if [ -c $f3 ]
  72 then
  73         /usr/bin/cat $f3 > $tmpdir/d3e$$
  74         f3=$tmpdir/d3e$$
  75 fi
  76 
  77 /usr/bin/diff $f1 $f3 > $tmpdir/d3a$$ 2> $tmpdir/d3a$$.err
  78 STATUS=$?
  79 if [ $STATUS -eq 1 ]
  80 then
  81         /usr/bin/grep -q "^[<>]" $tmpdir/d3a$$
  82         RET=$?
  83         if [ $RET -eq 1 ]
  84         then
  85                 /usr/bin/cat $tmpdir/d3a$$
  86                 exit $STATUS
  87         fi
  88 
  89         if [ $RET -gt 1 ]
  90         then
  91                 echo "diff3 failed" 1>&2
  92                 exit $STATUS
  93         fi
  94 fi
  95 
  96 if [ $STATUS -gt 1 ]
  97 then
  98         /usr/bin/cat $tmpdir/d3a$$.err
  99         exit $STATUS
 100 fi
 101 
 102 /usr/bin/diff $f2 $f3 > $tmpdir/d3b$$ 2> $tmpdir/d3b$$.err
 103 STATUS=$?
 104 if [ $STATUS -eq 1 ]
 105 then
 106         /usr/bin/grep -q "^[<>]" $tmpdir/d3b$$
 107         RET=$?
 108         if [ $RET -eq 1 ]
 109         then
 110                 /usr/bin/cat $tmpdir/d3b$$
 111                 exit $STATUS
 112         fi
 113 
 114         if [ $RET -gt 1 ]
 115         then
 116                 echo "diff3 failed" 1>&2
 117                 exit $STATUS
 118         fi
 119 fi
 120 
 121 if [ $STATUS -gt 1 ]
 122 then
 123         /usr/bin/cat $tmpdir/d3b$$.err
 124         exit $STATUS
 125 fi
 126