From d2d52addd50254d1b7c318c6784172d8d7de20c6 Mon Sep 17 00:00:00 2001 From: Alexander Pyhalov Date: Tue, 19 Dec 2017 08:48:38 +0300 Subject: [PATCH] 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 Reviewed by: Toomas Soome Reviewed by: Yuri Pankov Approved by: Robert Mustacchi --- usr/src/Makefile.lint | 2 - usr/src/cmd/Makefile | 5 - usr/src/cmd/diff3/diff3.sh | 6 +- usr/src/cmd/egrep/Makefile | 55 - usr/src/cmd/egrep/egrep.y | 1318 -------------------- usr/src/cmd/fgrep/Makefile | 44 - usr/src/cmd/fgrep/fgrep.c | 705 ----------- usr/src/cmd/{grep_xpg4 => grep}/Makefile | 26 +- usr/src/cmd/{grep_xpg4 => grep}/grep.c | 0 usr/src/cmd/grep/grep.xcl | 28 - usr/src/cmd/ldap/ns_ldap/idsconfig.sh | 2 +- usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh | 2 +- usr/src/cmd/tsol/misc/txzonemgr.sh | 2 +- usr/src/lib/libsaveargs/tests/functional/test.sh | 2 +- ...mishandles_return_value_of_its_child_process.sh | 2 +- usr/src/lib/libshell/misc/shell_styleguide.docbook | 6 +- usr/src/man/man1/egrep.1 | 142 +-- usr/src/man/man1/fgrep.1 | 88 +- usr/src/man/man1/grep.1 | 302 ++--- usr/src/man/man1/locale.1 | 12 +- usr/src/pkg/manifests/SUNWcs.mf | 4 +- usr/src/pkg/manifests/system-test-utiltest.mf | 5 + usr/src/pkg/manifests/system-xopen-xcu4.mf | 6 +- .../test/util-tests/tests/grep_xpg4/files/Makefile | 7 +- .../test/util-tests/tests/grep_xpg4/grep_test.ksh | 2 +- .../tests/functional/acl/acl_common.kshlib | 2 +- usr/src/tools/scripts/elfcmp.sh | 4 +- 27 files changed, 230 insertions(+), 2549 deletions(-) delete mode 100644 usr/src/cmd/egrep/Makefile delete mode 100644 usr/src/cmd/egrep/egrep.y delete mode 100644 usr/src/cmd/fgrep/Makefile delete mode 100644 usr/src/cmd/fgrep/fgrep.c rename usr/src/cmd/{grep_xpg4 => grep}/Makefile (73%) rename usr/src/cmd/{grep_xpg4 => grep}/grep.c (100%) delete mode 100644 usr/src/cmd/grep/grep.xcl diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint index cb1805e5c4..18d2f2398a 100644 --- a/usr/src/Makefile.lint +++ b/usr/src/Makefile.lint @@ -128,7 +128,6 @@ COMMON_SUBDIRS = \ cmd/fdetach \ cmd/fdformat \ cmd/fdisk \ - cmd/fgrep \ cmd/file \ cmd/find \ cmd/fmthard \ @@ -156,7 +155,6 @@ COMMON_SUBDIRS = \ cmd/getopt \ cmd/gettext \ cmd/grep \ - cmd/grep_xpg4 \ cmd/groups \ cmd/halt \ cmd/head \ diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile index 0903d63b7b..7249f43cb1 100644 --- a/usr/src/cmd/Makefile +++ b/usr/src/cmd/Makefile @@ -141,7 +141,6 @@ COMMON_SUBDIRS= \ echo \ ed \ eeprom \ - egrep \ eject \ emul64ioctl \ enhance \ @@ -159,7 +158,6 @@ COMMON_SUBDIRS= \ fdisk \ ficl \ filesync \ - fgrep \ file \ find \ flowadm \ @@ -187,7 +185,6 @@ COMMON_SUBDIRS= \ gettext \ gettxt \ grep \ - grep_xpg4 \ groups \ growfs \ grpck \ @@ -574,7 +571,6 @@ MSGSUBDIRS= \ expand \ expr \ fcinfo \ - fgrep \ file \ filesync \ find \ @@ -591,7 +587,6 @@ MSGSUBDIRS= \ gettext \ gettxt \ grep \ - grep_xpg4 \ grpck \ gss \ halt \ diff --git a/usr/src/cmd/diff3/diff3.sh b/usr/src/cmd/diff3/diff3.sh index fe115c517e..f29059a587 100644 --- a/usr/src/cmd/diff3/diff3.sh +++ b/usr/src/cmd/diff3/diff3.sh @@ -27,8 +27,6 @@ # Copyright (c) 1999, 2001 by Sun Microsystems, Inc. # All rights reserved. -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */ - usage="usage: diff3 file1 file2 file3" # mktmpdir - Create a private (mode 0700) temporary directory inside of /tmp @@ -80,7 +78,7 @@ fi STATUS=$? if [ $STATUS -eq 1 ] then - /usr/xpg4/bin/grep -q "^[<>]" $tmpdir/d3a$$ + /usr/bin/grep -q "^[<>]" $tmpdir/d3a$$ RET=$? if [ $RET -eq 1 ] then @@ -105,7 +103,7 @@ fi STATUS=$? if [ $STATUS -eq 1 ] then - /usr/xpg4/bin/grep -q "^[<>]" $tmpdir/d3b$$ + /usr/bin/grep -q "^[<>]" $tmpdir/d3b$$ RET=$? if [ $RET -eq 1 ] then diff --git a/usr/src/cmd/egrep/Makefile b/usr/src/cmd/egrep/Makefile deleted file mode 100644 index fde0fabcbe..0000000000 --- a/usr/src/cmd/egrep/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -PROG= egrep - -include ../Makefile.cmd - -CPPFLAGS += -D_FILE_OFFSET_BITS=64 -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-implicit-function-declaration -CERRWARN += -_gcc=-Wno-unused-variable -CERRWARN += -_gcc=-Wno-unused-label - -.KEEP_STATE: - -all: $(PROG) - -install: all $(ROOTPROG) - -$(PROG).c: $(PROG).y - $(YACC.y) $< - $(SED) '-e 1 a\ - \#define yyerror_gettext(x) yyerror(gettext(x))' y.tab.c > y1.c - $(SED) '-e /syntax/ s/yyerror/yyerror_gettext/' y1.c > $@ - $(RM) y1.c y.tab.c - -clean: - $(RM) $(PROG).c - -lint: lint_PROG - -include ../Makefile.targ diff --git a/usr/src/cmd/egrep/egrep.y b/usr/src/cmd/egrep/egrep.y deleted file mode 100644 index 8068dc447e..0000000000 --- a/usr/src/cmd/egrep/egrep.y +++ /dev/null @@ -1,1318 +0,0 @@ -%{ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -%} -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* Copyright (c) 1987, 1988 Microsoft Corporation */ -/* All Rights Reserved */ - -/* - * Copyright 2013 Damian Bogel. All rights reserved. - */ - -/* - * egrep -- print lines containing (or not containing) a regular expression - * - * status returns: - * 0 - ok, and some matches - * 1 - ok, but no matches - * 2 - some error; matches irrelevant - */ -%token CHAR MCHAR DOT MDOT CCL NCCL MCCL NMCCL OR CAT STAR PLUS QUEST -%left OR -%left CHAR MCHAR DOT CCL NCCL MCCL NMCCL '(' -%left CAT -%left STAR PLUS QUEST - -%{ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define STDIN_FILENAME gettext("(standard input)") - -#define BLKSIZE 512 /* size of reported disk blocks */ -#define EBUFSIZ 8192 -#define MAXLIN 350 -#define NCHARS 256 -#define MAXPOS 4000 -#define NSTATES 64 -#define FINAL -1 -#define RIGHT '\n' /* serves as record separator and as $ */ -#define LEFT '\n' /* beginning of line */ -int gotofn[NSTATES][NCHARS]; -int state[NSTATES]; -int out[NSTATES]; -int line = 1; -int *name; -int *left; -int *right; -int *parent; -int *foll; -int *positions; -char *chars; -wchar_t *lower; -wchar_t *upper; -int maxlin, maxclin, maxwclin, maxpos; -int nxtpos = 0; -int inxtpos; -int nxtchar = 0; -int *tmpstat; -int *initstat; -int istat; -int nstate = 1; -int xstate; -int count; -int icount; -char *input; - - -wchar_t lyylval; -wchar_t nextch(); -wchar_t maxmin(); -int compare(); -void overflo(); - -char reinit = 0; - -long long lnum; -int bflag; -int cflag; -int eflag; -int fflag; -int Hflag; -int hflag; -int iflag; -int lflag; -int nflag; -int qflag; -int vflag; -int nfile; -long long blkno; -long long tln; -int nsucc; -int badbotch; -extern char *optarg; -extern int optind; - -int f; -FILE *expfile; -%} - -%% -s: t - { - unary(FINAL, $1); - line--; - } - ; -t: b r - { $$ = node(CAT, $1, $2); } - | OR b r OR - { $$ = node(CAT, $2, $3); } - | OR b r - { $$ = node(CAT, $2, $3); } - | b r OR - { $$ = node(CAT, $1, $2); } - ; -b: - { /* if(multibyte) - $$ = mdotenter(); - else */ - $$ = enter(DOT); - $$ = unary(STAR, $$); - } - ; -r: CHAR - { $$ = iflag && isalpha($1) ? - node(OR, enter(tolower($1)), enter(toupper($1))) : enter($1); } - | MCHAR - { $$ = (iflag && iswalpha(lyylval)) ? - node(OR, mchar(towlower(lyylval)), mchar(towupper(lyylval))) : - mchar(lyylval); } - | DOT - { if(multibyte) - $$ = mdotenter(); - else - $$ = enter(DOT); - } - | CCL - { $$ = cclenter(CCL); } - | NCCL - { $$ = cclenter(NCCL); } - | MCCL - { $$ = ccl(CCL); } - | NMCCL - { $$ = ccl(NCCL); } - ; - -r: r OR r - { $$ = node(OR, $1, $3); } - | r r %prec CAT - { $$ = node(CAT, $1, $2); } - | r STAR - { $$ = unary(STAR, $1); } - | r PLUS - { $$ = unary(PLUS, $1); } - | r QUEST - { $$ = unary(QUEST, $1); } - | '(' r ')' - { $$ = $2; } - | error - ; - -%% -void add(int *, int); -void clearg(void); -void execute(char *); -void follow(int); -int mgetc(void); -void synerror(void); - - -void -yyerror(char *s) -{ - fprintf(stderr, "egrep: %s\n", s); - exit(2); -} - -int -yylex(void) -{ - extern int yylval; - int cclcnt, x, ccount, oldccount; - wchar_t c, lc; - - c = nextch(); - switch(c) { - case '^': - yylval = LEFT; - return(CHAR); - case '$': - c = RIGHT; - goto defchar; - case '|': return (OR); - case '*': return (STAR); - case '+': return (PLUS); - case '?': return (QUEST); - case '(': return (c); - case ')': return (c); - case '.': return(DOT); - case '\0': return (0); - case RIGHT: return (OR); - case '[': - x = (multibyte ? MCCL : CCL); - cclcnt = 0; - count = nxtchar++; - if ((c = nextch()) == '^') { - x = (multibyte ? NMCCL : NCCL); - c = nextch(); - } - lc = 0; - do { - if (iflag && iswalpha(c)) - c = towlower(c); - if (c == '\0') synerror(); - if (c == '-' && cclcnt > 0 && lc != 0) { - if ((c = nextch()) != 0) { - if(c == ']') { - chars[nxtchar++] = '-'; - cclcnt++; - break; - } - if (iflag && iswalpha(c)) - c = towlower(c); - if (!multibyte || - (c & WCHAR_CSMASK) == (lc & WCHAR_CSMASK) && - lc < c && - !iswcntrl(c) && !iswcntrl(lc)) { - if (nxtchar >= maxclin) - if (allocchars() == 0) - overflo(); - chars[nxtchar++] = '-'; - cclcnt++; - } - } - } - ccount = oldccount = nxtchar; - if(ccount + MB_LEN_MAX >= maxclin) - if(allocchars() == 0) - overflo(); - ccount += wctomb(&chars[ccount], c); - cclcnt += ccount - oldccount; - nxtchar += ccount - oldccount; - lc = c; - } while ((c = nextch()) != ']'); - chars[count] = cclcnt; - return(x); - - case '\\': - if ((c = nextch()) == '\0') synerror(); - defchar: - default: - if (c <= 0177) { - yylval = c; - return (CHAR); - } else { - lyylval = c; - return (MCHAR); - } - } -} - -wchar_t -nextch(void) -{ - wchar_t lc; - char multic[MB_LEN_MAX]; - int length, d; - if (fflag) { - if ((length = _mbftowc(multic, &lc, mgetc, &d)) < 0) - synerror(); - if(length == 0) - lc = '\0'; - } - else { - if((length = mbtowc(&lc, input, MB_LEN_MAX)) == -1) - synerror(); - if(length == 0) - return(0); - input += length; - } - return(lc); -} - -int -mgetc(void) -{ - return(getc(expfile)); -} - -void -synerror(void) -{ - fprintf(stderr, gettext("egrep: syntax error\n")); - exit(2); -} - -int -enter(int x) -{ - if(line >= maxlin) - if(alloctree() == 0) - overflo(); - name[line] = x; - left[line] = 0; - right[line] = 0; - return(line++); -} - -int -cclenter(int x) -{ - int linno; - linno = enter(x); - right[linno] = count; - return (linno); -} - -int -node(int x, int l, int r) -{ - if(line >= maxlin) - if(alloctree() == 0) - overflo(); - name[line] = x; - left[line] = l; - right[line] = r; - parent[l] = line; - parent[r] = line; - return(line++); -} - -int -unary(int x, int d) -{ - if(line >= maxlin) - if(alloctree() == 0) - overflo(); - name[line] = x; - left[line] = d; - right[line] = 0; - parent[d] = line; - return(line++); -} - -int -allocchars(void) -{ - maxclin += MAXLIN; - if((chars = realloc(chars, maxclin)) == (char *)0) - return 0; - return 1; -} - -int -alloctree(void) -{ - maxlin += MAXLIN; - if((name = (int *)realloc(name, maxlin*sizeof(int))) == (int *)0) - return 0; - if((left = (int *)realloc(left, maxlin*sizeof(int))) == (int *)0) - return 0; - if((right = (int *)realloc(right, maxlin*sizeof(int))) == (int *)0) - return 0; - if((parent = (int *)realloc(parent, maxlin*sizeof(int))) == (int *)0) - return 0; - if((foll = (int *)realloc(foll, maxlin*sizeof(int))) == (int *)0) - return 0; - if((tmpstat = (int *)realloc(tmpstat, maxlin*sizeof(int))) == (int *)0) - return 0; - if((initstat = (int *)realloc(initstat, maxlin*sizeof(int))) == (int *)0) - return 0; - return 1; -} - -void -overflo(void) -{ - fprintf(stderr, gettext("egrep: regular expression too long\n")); - exit(2); -} - -void -cfoll(int v) -{ - int i; - if (left[v] == 0) { - count = 0; - for (i=1; i<=line; i++) tmpstat[i] = 0; - follow(v); - add(foll, v); - } - else if (right[v] == 0) cfoll(left[v]); - else { - cfoll(left[v]); - cfoll(right[v]); - } -} - -void -cgotofn(void) -{ - int i; - count = 0; - inxtpos = nxtpos; - for (i=3; i<=line; i++) tmpstat[i] = 0; - if (cstate(line-1)==0) { - tmpstat[line] = 1; - count++; - out[1] = 1; - } - for (i=3; i<=line; i++) initstat[i] = tmpstat[i]; - count--; /*leave out position 1 */ - icount = count; - tmpstat[1] = 0; - add(state, 1); - istat = nxtst(1, LEFT); -} - -int -nxtst(int s, int c) -{ - int i, num, k; - int pos, curpos, number, newpos; - num = positions[state[s]]; - count = icount; - for (i=3; i<=line; i++) tmpstat[i] = initstat[i]; - pos = state[s] + 1; - for (i=0; i= 0) - if ( - (k == c) - || (k == DOT && dot(c)) - || (k == MDOT && mdot(c)) - || (k == CCL && dot(c) && member(c, right[curpos], 1)) - || (k == NCCL && dot(c) && member(c, right[curpos], 0)) - || (k == MCCL && mdot(c) && member(c, right[curpos], 1)) - ) { - number = positions[foll[curpos]]; - newpos = foll[curpos] + 1; - for (k=0; k= NSTATES) { - for (i=1; i= 0200 && (!iscntrl(c) || c == SS2 && eucw2 || c == SS3 && eucw3)) - return(0); - if(c == RIGHT || c == LEFT) - return(0); - return(1); -} - -int -mdot(int c) -{ - if(c >= 0200 && !iscntrl(c)) - return(1); - return(0); -} - -int -member(int symb, int set, int torf) -{ - int i, num, pos, c, lc; - if(symb == RIGHT || symb == LEFT) - return(0); - num = chars[set]; - pos = set + 1; - lc = 0; - if(iflag) - symb = tolower(symb); - for (i=0; i= maxpos) { - maxpos += MAXPOS + count; - if((positions = (int *)realloc(positions, maxpos *sizeof(int))) == (int *)0) - overflo(); - } - array[n] = nxtpos; - positions[nxtpos++] = count; - for (i=3; i <= line; i++) { - if (tmpstat[i] == 1) { - positions[nxtpos++] = i; - } - } -} - -void -follow(int v) -{ - int p; - if (v == line) return; - p = parent[v]; - switch(name[p]) { - case STAR: - case PLUS: cstate(v); - follow(p); - return; - - case OR: - case QUEST: follow(p); - return; - - case CAT: if (v == left[p]) { - if (cstate(right[p]) == 0) { - follow(p); - return; - } - } - else follow(p); - return; - case FINAL: if (tmpstat[line] != 1) { - tmpstat[line] = 1; - count++; - } - return; - } -} - -#define USAGE "[ -bchHilnsqv ] [ -e exp ] [ -f file ] [ strings ] [ file ] ..." - -int -main(int argc, char **argv) -{ - char c; - char nl = '\n'; - int errflag = 0; - - (void)setlocale(LC_ALL, ""); - -#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ - #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't. */ -#endif - (void) textdomain(TEXT_DOMAIN); - - while((c = getopt(argc, argv, "ybcie:f:Hhlnvsq")) != -1) - switch(c) { - - case 'b': - bflag++; - continue; - - case 'c': - cflag++; - continue; - - case 'e': - eflag++; - input = optarg; - continue; - - case 'f': - fflag++; - expfile = fopen(optarg, "r"); - if(expfile == NULL) { - fprintf(stderr, - gettext("egrep: can't open %s\n"), optarg); - exit(2); - } - continue; - - case 'H': - if (!lflag) /* H is excluded by l as in GNU grep */ - Hflag++; - hflag = 0; /* H excludes h */ - continue; - - case 'h': - hflag++; - Hflag = 0; /* h excludes H */ - continue; - - case 'y': - case 'i': - iflag++; - continue; - - case 'l': - lflag++; - Hflag = 0; /* l excludes H */ - continue; - - case 'n': - nflag++; - continue; - - case 'q': - case 's': /* Solaris: legacy option */ - qflag++; - continue; - - case 'v': - vflag++; - continue; - - case '?': - errflag++; - } - if (errflag || ((argc <= 0) && !fflag && !eflag)) { - fprintf(stderr, gettext("usage: egrep %s\n"), gettext(USAGE)); - exit(2); - } - if(!eflag && !fflag) { - input = argv[optind]; - optind++; - } - - argc -= optind; - argv = &argv[optind]; - - /* allocate initial space for arrays */ - if((name = (int *)malloc(MAXLIN*sizeof(int))) == (int *)0) - overflo(); - if((left = (int *)malloc(MAXLIN*sizeof(int))) == (int *)0) - overflo(); - if((right = (int *)malloc(MAXLIN*sizeof(int))) == (int *)0) - overflo(); - if((parent = (int *)malloc(MAXLIN*sizeof(int))) == (int *)0) - overflo(); - if((foll = (int *)malloc(MAXLIN*sizeof(int))) == (int *)0) - overflo(); - if((tmpstat = (int *)malloc(MAXLIN*sizeof(int))) == (int *)0) - overflo(); - if((initstat = (int *)malloc(MAXLIN*sizeof(int))) == (int *)0) - overflo(); - if((chars = (char *)malloc(MAXLIN)) == (char *)0) - overflo(); - if((lower = (wchar_t *)malloc(MAXLIN*sizeof(wchar_t))) == (wchar_t *)0) - overflo(); - if((upper = (wchar_t *)malloc(MAXLIN*sizeof(wchar_t))) == (wchar_t *)0) - overflo(); - if((positions = (int *)malloc(MAXPOS*sizeof(int))) == (int *)0) - overflo(); - maxlin = MAXLIN; - maxclin = MAXLIN; - maxwclin = MAXLIN; - maxpos = MAXPOS; - - yyparse(); - - cfoll(line-1); - cgotofn(); - nfile = argc; - if (argc<=0) { - execute(0); - } - else while (--argc >= 0) { - if (reinit == 1) clearg(); - execute(*argv++); - } - return (badbotch ? 2 : nsucc==0); -} - -void -execute(char *file) -{ - char *p; - int cstat; - wchar_t c; - int t; - long count; - long count1, count2; - long nchars; - int succ; - char *ptr, *ptrend, *lastptr; - char *buf; - long lBufSiz; - FILE *f; - int nlflag; - - lBufSiz = EBUFSIZ; - if ((buf = malloc (lBufSiz + EBUFSIZ)) == NULL) { - exit (2); /* out of memory - BAIL */ - } - - if (file) { - if ((f = fopen(file, "r")) == NULL) { - fprintf(stderr, - gettext("egrep: can't open %s\n"), file); - badbotch=1; - return; - } - } else { - f = stdin; - file = STDIN_FILENAME; - } - lnum = 1; - tln = 0; - if((count = read(fileno(f), buf, EBUFSIZ)) <= 0) { - fclose(f); - - if (cflag && !qflag) { - if (Hflag || (nfile > 1 && !hflag)) - fprintf(stdout, "%s:", file); - fprintf(stdout, "%lld\n", tln); - } - return; - } - - blkno = count; - ptr = buf; - for(;;) { - if((ptrend = memchr(ptr, '\n', buf + count - ptr)) == NULL) { - /* - move the unused partial record to the head of the buffer - */ - if (ptr > buf) { - count = buf + count - ptr; - memmove (buf, ptr, count); - ptr = buf; - } - - /* - Get a bigger buffer if this one is full - */ - if(count > lBufSiz) { - /* - expand the buffer - */ - lBufSiz += EBUFSIZ; - if ((buf = realloc (buf, lBufSiz + EBUFSIZ)) == NULL) { - exit (2); /* out of memory - BAIL */ - } - - ptr = buf; - } - - p = buf + count; - if((count1 = read(fileno(f), p, EBUFSIZ)) > 0) { - count += count1; - blkno += count1; - continue; - } - ptrend = ptr + count; - nlflag = 0; - } else - nlflag = 1; - *ptrend = '\n'; - p = ptr; - lastptr = ptr; - cstat = istat; - succ = 0; - for(;;) { - if(out[cstat]) { - if(multibyte && p > ptr) { - wchar_t wchar; - int length; - char *endptr = p; - p = lastptr; - while(p < endptr) { - length = mbtowc(&wchar, p, MB_LEN_MAX); - if(length <= 1) - p++; - else - p += length; - } - if(p == endptr) { - succ = !vflag; - break; - } - cstat = 1; - length = mbtowc(&wchar, lastptr, MB_LEN_MAX); - if(length <= 1) - lastptr++; - else - lastptr += length; - p = lastptr; - continue; - } - succ = !vflag; - break; - } - c = (unsigned char)*p++; - if ((t = gotofn[cstat][c]) == 0) - cstat = nxtst(cstat, c); - else - cstat = t; - if(c == RIGHT) { - if(out[cstat]) { - succ = !vflag; - break; - } - succ = vflag; - break; - } - } - if (succ) { - nsucc = 1; - if (lflag || qflag) { - if (!qflag) - (void) printf("%s\n", file); - fclose(f); - return; - } - if (cflag) { - tln++; - } else { - if (Hflag || (nfile > 1 && !hflag)) - printf("%s:", file); - if (bflag) { - nchars = blkno - (buf + count - ptrend) - 2; - if(nlflag) - nchars++; - printf("%lld:", nchars/BLKSIZE); - } - if (nflag) - printf("%lld:", lnum); - if(nlflag) - nchars = ptrend - ptr + 1; - else - nchars = ptrend - ptr; - fwrite(ptr, (size_t)1, (size_t)nchars, stdout); - } - } - if(!nlflag) - break; - ptr = ptrend + 1; - if(ptr >= buf + count) { - ptr = buf; - if((count = read(fileno(f), buf, EBUFSIZ)) <= 0) - break; - blkno += count; - } - lnum++; - if (reinit == 1) - clearg(); - } - fclose(f); - if (cflag && !qflag) { - if (Hflag || (nfile > 1 && !hflag)) - printf("%s:", file); - printf("%lld\n", tln); - } -} - -void -clearg(void) -{ - int i, k; - for (i=1; i<=nstate; i++) - out[i] = 0; - for (i=1; i<=nstate; i++) - for (k=0; k 0) - /* single byte part of character class */ - x2 = cclenter(type); - else if(type == NCCL) - /* all single byte characters match */ - x2 = enter(DOT); - while(current <= last) { - if(upper[current] == lower[current]) - x1 = mchar(lower[current]); - else { - length = wctomb(multic1, lower[current]); - wctomb(multic2, upper[current]); - x1 = range((unsigned char *)multic1, - (unsigned char *)multic2, length); - } - if(x2) - x2 = node(OR, x2, x1); - else - x2 = x1; - current++; - } - return x2; -} - -int -range(unsigned char *p1, unsigned char *p2, int length) -{ - char multic[MB_LEN_MAX+1]; - char *p; - int i, x1, x2; - if(length == 1) - return(classenter(*p1, *p2)); - if(p1[0] == p2[0]) - return(node(CAT, enter(p1[0]), range(p1+1, p2+1, length - 1))); - p = multic; - for(i = 1; i < length; i++) - *p++ = 0377; - x1 = node(CAT, enter(p1[0]), - range(p1+1, (unsigned char *)multic, length - 1)); - if((unsigned char)(p1[0] + 1) < p2[0]) { - x2 = classenter(p1[0] + 1, p2[0] - 1); - for(i = 1; i < length; i++) - x2 = node(CAT, x2, enter(MDOT)); - x1 = node(OR, x1, x2); - } - p = multic; - for(i = 1; i < length; i++) - *p++ = 0200; - x2 = node(CAT, enter(p2[0]), - range((unsigned char *)multic, p2+1, length - 1)); - return node(OR, x1, x2); -} - -int -classenter(int x1, int x2) -{ - static int max, min; - if(!max) { - int i; - for(i = 0200; i <= 0377; i++) - if(!iscntrl(i)) - break; - min = i; - for(i = 0377; i >= 0200; i--) - if(!iscntrl(i)) - break; - max = i; - } - if(x1 <= min && x2 >= max) - return enter(MDOT); - if(nxtchar + 4 >= maxclin) - if(allocchars() == 0) - overflo(); - count = nxtchar++; - chars[nxtchar++] = x1; - chars[nxtchar++] = '-'; - chars[nxtchar++] = x2; - chars[count] = 3; - return cclenter(MCCL); -} - -int -genrange(int type) -{ - char *p, *endp; - int current, nel, i, last, length; - wchar_t c, lc; - - current = 0; - p = &chars[count+1]; - endp = &chars[count+1] + chars[count]; - lc = 0; - - /* convert character class into union of ranges */ - while(p < endp) { - length = mbtowc(&c, p, MB_LEN_MAX); - p += length; - if(c == '-' && lc != 0) { - length = mbtowc(&c, p, MB_LEN_MAX); - upper[current-1] = c; - p += length; - } else { - lower[current] = c; - upper[current++] = c; - } - lc = c; - } - nel = current; - /* sort lower and upper bounds of ranges */ - qsort((char *)lower, nel, sizeof(wchar_t), compare); - qsort((char *)upper, nel, sizeof(wchar_t), compare); - last = current - 1; - current = 0; - /* combine overlapping or adjacent ranges */ - for(i = 0; i < last; i++) - if(upper[i] >= lower[i+1] - 1) - upper[current] = upper[i+1]; - else { - lower[++current] = lower[i+1]; - upper[current] = upper[i+1]; - } - if(type == NCCL) { - /* find complement of character class */ - int j, next; - i = 0; - while(i <= current && isascii(c=lower[i]) || c <= 0377 && iscntrl(c)) - i++; - if(i > current) { - /* match all multibyte characters */ - if(eucw2) { - lower[i] = maxmin(WCHAR_CS2, 0); - upper[i++] = maxmin(WCHAR_CS2, 1); - } - if(eucw3) { - lower[i] = maxmin(WCHAR_CS3, 0); - upper[i++] = maxmin(WCHAR_CS3, 1); - } - lower[i] = maxmin(WCHAR_CS1, 0); - upper[i++] = maxmin(WCHAR_CS1, 1); - return i - 1; - } - next = current + 1; - if(next + current + 2 >= maxwclin) { - maxwclin += MAXLIN + next + current + 2; - if((lower = (wchar_t *)realloc(lower, maxwclin *sizeof(wchar_t))) == (wchar_t *)0 || - (upper = (wchar_t *)realloc(upper, maxwclin * sizeof(wchar_t))) == (wchar_t *)0) - overflo(); - } - if(eucw2 && lower[i] > maxmin(WCHAR_CS2, 0)) { - lower[next] = maxmin(WCHAR_CS2, 0); - if((lower[i] & WCHAR_CSMASK) != WCHAR_CS2) { - upper[next++] = maxmin(WCHAR_CS2, 1); - if((lower[i] & WCHAR_CSMASK) == WCHAR_CS1 && eucw3) { - lower[next] = maxmin(WCHAR_CS3, 0); - upper[next++] = maxmin(WCHAR_CS3, 1); - } - if(lower[i] > maxmin(lower[i] & WCHAR_CSMASK, 0)) { - lower[next] = maxmin(lower[i] & WCHAR_CSMASK, 0); - upper[next++] = lower[i] - 1; - } - } else - upper[next++] = lower[i] - 1; - } else if(lower[i] > maxmin(lower[i] & WCHAR_CSMASK, 0)) { - lower[next] = maxmin(lower[i] & WCHAR_CSMASK, 0); - upper[next++] = lower[i] - 1; - } - for(j = i; j < current; j++) { - if(upper[j] < maxmin(upper[j] & WCHAR_CSMASK, 1)) { - lower[next] = upper[j] + 1; - if((upper[j] & WCHAR_CSMASK) != (lower[j+1] & WCHAR_CSMASK)) { - upper[next++] = maxmin(upper[j] & WCHAR_CSMASK, 1); - if(eucw3 && (upper[j] & WCHAR_CSMASK) == WCHAR_CS2 && (lower[j+1] & WCHAR_CSMASK) == WCHAR_CS1) { - lower[next] = maxmin(WCHAR_CS3, 0); - upper[next++] = maxmin(WCHAR_CS3, 1); - } - if(lower[j+1] > maxmin(lower[j+1] & WCHAR_CSMASK, 0)) { - lower[next] = maxmin(lower[j+1] & WCHAR_CSMASK, 0); - upper[next++] = lower[j+1] - 1; - } - } else - upper[next++] = lower[j+1] - 1; - } else if(lower[j+1] > maxmin(lower[j+1], 0)) { - lower[next] = maxmin(lower[j+1], 0); - upper[next++] = lower[j+1] - 1; - } - } - if(upper[current] < maxmin(upper[current] & WCHAR_CSMASK, 1)) { - lower[next] = upper[current] + 1; - upper[next++] = maxmin(upper[current] & WCHAR_CSMASK, 1); - } - if((upper[current] & WCHAR_CSMASK) != WCHAR_CS1) { - if((upper[current] & WCHAR_CSMASK) == WCHAR_CS2 && eucw3) { - lower[next] = maxmin(WCHAR_CS3, 0); - upper[next++] = maxmin(WCHAR_CS3, 1); - } - lower[next] = maxmin(WCHAR_CS1, 0); - upper[next++] = maxmin(WCHAR_CS1, 1); - } - for(j = current + 1; j < next; j++) { - lower[i] = lower[j]; - upper[i++] = upper[j]; - } - current = i - 1; - } - return(current); -} - -int -compare(wchar_t *c, wchar_t *d) -{ - if(*c < *d) - return -1; - if(*c == *d) - return 0; - return 1; -} - -wchar_t -maxmin(wchar_t c, int flag) -{ - static wchar_t minmax1[2], minmax2[2], minmax3[2]; - - if(!minmax1[0]) { - /* compute min and max process codes for all code sets */ - int length, i; - char multic[MB_LEN_MAX], minmax[2]; - for(i = 0377; i >= 0200; i--) - if(!iscntrl(i)) - break; - minmax[1] = i; - for(i = 0240; i <= 0377; i++) - if(!iscntrl(i)) - break; - minmax[0] = i; - for(i = 0; i <= 1; i++) { - length = MB_LEN_MAX; - while(length--) - multic[length] = minmax[i]; - mbtowc(&minmax1[i], multic, MB_LEN_MAX); - if(eucw2) { - multic[0] = SS2; - mbtowc(&minmax2[i], multic, MB_LEN_MAX); - } - if(eucw3) { - multic[0] = SS3; - mbtowc(&minmax3[i], multic, MB_LEN_MAX); - } - } - } - switch(c) { - case WCHAR_CS1: return minmax1[flag]; - case WCHAR_CS2: return minmax2[flag]; - case WCHAR_CS3: return minmax3[flag]; - } - - /* NOTREACHED */ - return (0); -} diff --git a/usr/src/cmd/fgrep/Makefile b/usr/src/cmd/fgrep/Makefile deleted file mode 100644 index 26d8ef046c..0000000000 --- a/usr/src/cmd/fgrep/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 1989,1996 by Sun Microsystems, Inc. -# All rights reserved. -# - -PROG= fgrep - -include ../Makefile.cmd - -CPPFLAGS += -D_FILE_OFFSET_BITS=64 -CERRWARN += -_gcc=-Wno-parentheses - -.KEEP_STATE: - -all: $(PROG) - -install: all $(ROOTPROG) - -clean: - -lint: lint_PROG - -include ../Makefile.targ diff --git a/usr/src/cmd/fgrep/fgrep.c b/usr/src/cmd/fgrep/fgrep.c deleted file mode 100644 index 31724cda40..0000000000 --- a/usr/src/cmd/fgrep/fgrep.c +++ /dev/null @@ -1,705 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* Copyright (c) 1987, 1988 Microsoft Corporation */ -/* All Rights Reserved */ - -/* - * Copyright 2013 Damian Bogel. All rights reserved. - */ - -/* - * fgrep -- print all lines containing any of a set of keywords - * - * status returns: - * 0 - ok, and some matches - * 1 - ok, but no matches - * 2 - some error - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -eucwidth_t WW; -#define WIDTH1 WW._eucw1 -#define WIDTH2 WW._eucw2 -#define WIDTH3 WW._eucw3 -#define MULTI_BYTE WW._multibyte -#define GETONE(lc, p) \ - cw = ISASCII(lc = (unsigned char)*p++) ? 1 : \ - (ISSET2(lc) ? WIDTH2 : \ - (ISSET3(lc) ? WIDTH3 : WIDTH1)); \ - if (--cw > --ccount) { \ - cw -= ccount; \ - while (ccount--) \ - lc = (lc << 7) | ((*p++) & 0177); \ - if (p >= &buf[fw_lBufsiz + BUFSIZ]) { \ - if (nlp == buf) { \ - /* Increase the buffer size */ \ - fw_lBufsiz += BUFSIZ; \ - if ((buf = realloc(buf, \ - fw_lBufsiz + BUFSIZ)) == NULL) { \ - exit(2); /* out of memory */ \ - } \ - nlp = buf; \ - p = &buf[fw_lBufsiz]; \ - } else { \ - /* shift the buffer contents down */ \ - (void) memmove(buf, nlp, \ - &buf[fw_lBufsiz + BUFSIZ] - nlp);\ - p -= nlp - buf; \ - nlp = buf; \ - } \ - } \ - if (p > &buf[fw_lBufsiz]) { \ - if ((ccount = fread(p, sizeof (char), \ - &buf[fw_lBufsiz + BUFSIZ] - p, fptr))\ - <= 0) break; \ - } else if ((ccount = fread(p, \ - sizeof (char), BUFSIZ, fptr)) <= 0) \ - break; \ - blkno += (long long)ccount; \ - } \ - ccount -= cw; \ - while (cw--) \ - lc = (lc << 7) | ((*p++) & 0177) - -/* - * The same() macro and letter() function were inserted to allow for - * the -i option work for the multi-byte environment. - */ -wchar_t letter(); -#define same(a, b) \ - (a == b || iflag && (!MULTI_BYTE || ISASCII(a)) && (a ^ b) == ' ' && \ - letter(a) == letter(b)) - -#define STDIN_FILENAME gettext("(standard input)") - -#define QSIZE 400 -struct words { - wchar_t inp; - char out; - struct words *nst; - struct words *link; - struct words *fail; -} *w = NULL, *smax, *q; - -FILE *fptr; -long long lnum; -int bflag, cflag, lflag, fflag, nflag, vflag, xflag, eflag, qflag; -int Hflag, hflag, iflag; -int retcode = 0; -int nfile; -long long blkno; -int nsucc; -long long tln; -FILE *wordf; -char *argptr; -off_t input_size = 0; - -void execute(char *); -void cgotofn(void); -void overflo(void); -void cfail(void); - -static long fw_lBufsiz = 0; - -int -main(int argc, char **argv) -{ - int c; - int errflg = 0; - struct stat file_stat; - - (void) setlocale(LC_ALL, ""); -#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ -#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */ -#endif - (void) textdomain(TEXT_DOMAIN); - - while ((c = getopt(argc, argv, "Hhybcie:f:lnvxqs")) != EOF) - switch (c) { - - case 'q': - case 's': /* Solaris: legacy option */ - qflag++; - continue; - case 'H': - Hflag++; - hflag = 0; - continue; - case 'h': - hflag++; - Hflag = 0; - continue; - case 'b': - bflag++; - continue; - - case 'i': - case 'y': - iflag++; - continue; - - case 'c': - cflag++; - continue; - - case 'e': - eflag++; - argptr = optarg; - input_size = strlen(argptr); - continue; - - case 'f': - fflag++; - wordf = fopen(optarg, "r"); - if (wordf == NULL) { - (void) fprintf(stderr, - gettext("fgrep: can't open %s\n"), - optarg); - exit(2); - } - - if (fstat(fileno(wordf), &file_stat) == 0) { - input_size = file_stat.st_size; - } else { - (void) fprintf(stderr, - gettext("fgrep: can't fstat %s\n"), - optarg); - exit(2); - } - - continue; - - case 'l': - lflag++; - continue; - - case 'n': - nflag++; - continue; - - case 'v': - vflag++; - continue; - - case 'x': - xflag++; - continue; - - case '?': - errflg++; - } - - argc -= optind; - if (errflg || ((argc <= 0) && !fflag && !eflag)) { - (void) printf(gettext("usage: fgrep [ -bcHhilnqsvx ] " - "[ -e exp ] [ -f file ] [ strings ] [ file ] ...\n")); - exit(2); - } - if (!eflag && !fflag) { - argptr = argv[optind]; - input_size = strlen(argptr); - input_size++; - optind++; - argc--; - } - -/* - * Normally we need one struct words for each letter in the pattern - * plus one terminating struct words with outp = 1, but when -x option - * is specified we require one more struct words for `\n` character so we - * calculate the input_size as below. We add extra 1 because - * (input_size/2) rounds off odd numbers - */ - - if (xflag) { - input_size = input_size + (input_size/2) + 1; - } - - input_size++; - - w = (struct words *)calloc(input_size, sizeof (struct words)); - if (w == NULL) { - (void) fprintf(stderr, - gettext("fgrep: could not allocate " - "memory for wordlist\n")); - exit(2); - } - - getwidth(&WW); - if ((WIDTH1 == 0) && (WIDTH2 == 0) && - (WIDTH3 == 0)) { - /* - * If non EUC-based locale, - * assume WIDTH1 is 1. - */ - WIDTH1 = 1; - } - WIDTH2++; - WIDTH3++; - - cgotofn(); - cfail(); - nfile = argc; - argv = &argv[optind]; - if (argc <= 0) { - execute((char *)NULL); - } else - while (--argc >= 0) { - execute(*argv); - argv++; - } - - if (w != NULL) { - free(w); - } - - return (retcode != 0 ? retcode : nsucc == 0); -} - -void -execute(char *file) -{ - char *p; - struct words *c; - int ccount; - static char *buf = NULL; - int failed; - char *nlp; - wchar_t lc; - int cw; - - if (buf == NULL) { - fw_lBufsiz = BUFSIZ; - if ((buf = malloc(fw_lBufsiz + BUFSIZ)) == NULL) { - exit(2); /* out of memory */ - } - } - - if (file) { - if ((fptr = fopen(file, "r")) == NULL) { - (void) fprintf(stderr, - gettext("fgrep: can't open %s\n"), file); - retcode = 2; - return; - } - } else { - fptr = stdin; - file = STDIN_FILENAME; - } - ccount = 0; - failed = 0; - lnum = 1; - tln = 0; - blkno = 0; - p = buf; - nlp = p; - c = w; - for (;;) { - if (c == 0) - break; - if (ccount <= 0) { - if (p >= &buf[fw_lBufsiz + BUFSIZ]) { - if (nlp == buf) { - /* increase the buffer size */ - fw_lBufsiz += BUFSIZ; - if ((buf = realloc(buf, - fw_lBufsiz + BUFSIZ)) == NULL) { - exit(2); /* out of memory */ - } - nlp = buf; - p = &buf[fw_lBufsiz]; - } else { - /* shift the buffer down */ - (void) memmove(buf, nlp, - &buf[fw_lBufsiz + BUFSIZ] - - nlp); - p -= nlp - buf; - nlp = buf; - } - - } - if (p > &buf[fw_lBufsiz]) { - if ((ccount = fread(p, sizeof (char), - &buf[fw_lBufsiz + BUFSIZ] - p, fptr)) - <= 0) - break; - } else if ((ccount = fread(p, sizeof (char), - BUFSIZ, fptr)) <= 0) - break; - blkno += (long long)ccount; - } - GETONE(lc, p); -nstate: - if (same(c->inp, lc)) { - c = c->nst; - } else if (c->link != 0) { - c = c->link; - goto nstate; - } else { - c = c->fail; - failed = 1; - if (c == 0) { - c = w; -istate: - if (same(c->inp, lc)) { - c = c->nst; - } else if (c->link != 0) { - c = c->link; - goto istate; - } - } else - goto nstate; - } - - if (c == 0) - break; - - if (c->out) { - while (lc != '\n') { - if (ccount <= 0) { -if (p == &buf[fw_lBufsiz + BUFSIZ]) { - if (nlp == buf) { - /* increase buffer size */ - fw_lBufsiz += BUFSIZ; - if ((buf = realloc(buf, fw_lBufsiz + BUFSIZ)) == NULL) { - exit(2); /* out of memory */ - } - nlp = buf; - p = &buf[fw_lBufsiz]; - } else { - /* shift buffer down */ - (void) memmove(buf, nlp, &buf[fw_lBufsiz + BUFSIZ] - nlp); - p -= nlp - buf; - nlp = buf; - } -} -if (p > &buf[fw_lBufsiz]) { - if ((ccount = fread(p, sizeof (char), - &buf[fw_lBufsiz + BUFSIZ] - p, fptr)) <= 0) break; - } else if ((ccount = fread(p, sizeof (char), BUFSIZ, - fptr)) <= 0) break; - blkno += (long long)ccount; - } - GETONE(lc, p); -} - if ((vflag && (failed == 0 || xflag == 0)) || - (vflag == 0 && xflag && failed)) - goto nomatch; -succeed: - nsucc = 1; - if (lflag || qflag) { - if (!qflag) - (void) printf("%s\n", file); - (void) fclose(fptr); - return; - } - if (cflag) { - tln++; - } else { - if (Hflag || (nfile > 1 && !hflag)) - (void) printf("%s:", file); - if (bflag) - (void) printf("%lld:", - (blkno - (long long)(ccount-1)) - / BUFSIZ); - if (nflag) - (void) printf("%lld:", lnum); - if (p <= nlp) { - while (nlp < &buf[fw_lBufsiz + BUFSIZ]) - (void) putchar(*nlp++); - nlp = buf; - } - while (nlp < p) - (void) putchar(*nlp++); - } -nomatch: - lnum++; - nlp = p; - c = w; - failed = 0; - continue; - } - if (lc == '\n') - if (vflag) - goto succeed; - else { - lnum++; - nlp = p; - c = w; - failed = 0; - } - } - (void) fclose(fptr); - if (cflag && !qflag) { - if (Hflag || (nfile > 1 && !hflag)) - (void) printf("%s:", file); - (void) printf("%lld\n", tln); - } -} - - -wchar_t -getargc(void) -{ - /* appends a newline to shell quoted argument list so */ - /* the list looks like it came from an ed style file */ - wchar_t c; - int cw; - int b; - static int endflg; - - - if (wordf) { - if ((b = getc(wordf)) == EOF) - return (EOF); - cw = ISASCII(c = (wchar_t)b) ? 1 : - (ISSET2(c) ? WIDTH2 : (ISSET3(c) ? WIDTH3 : WIDTH1)); - while (--cw) { - if ((b = getc(wordf)) == EOF) - return (EOF); - c = (c << 7) | (b & 0177); - } - return (iflag ? letter(c) : c); - } - - if (endflg) - return (EOF); - - { - cw = ISASCII(c = (unsigned char)*argptr++) ? 1 : - (ISSET2(c) ? WIDTH2 : (ISSET3(c) ? WIDTH3 : WIDTH1)); - - while (--cw) - c = (c << 7) | ((*argptr++) & 0177); - if (c == '\0') { - endflg++; - return ('\n'); - } - } - return (iflag ? letter(c) : c); - - -} - -void -cgotofn(void) -{ - int c; - struct words *s; - - s = smax = w; -nword: - for (;;) { - c = getargc(); - if (c == EOF) - return; - if (c == 0) - goto enter; - if (c == '\n') { - if (xflag) { - for (;;) { - if (s->inp == c) { - s = s->nst; - break; - } - if (s->inp == 0) - goto nenter; - if (s->link == 0) { - if (smax >= &w[input_size -1]) - overflo(); - s->link = ++smax; - s = smax; - goto nenter; - } - s = s->link; - } - } - s->out = 1; - s = w; - } else { -loop: - if (s->inp == c) { - s = s->nst; - continue; - } - if (s->inp == 0) - goto enter; - if (s->link == 0) { - if (smax >= &w[input_size -1]) - overflo(); - s->link = ++smax; - s = smax; - goto enter; - } - s = s->link; - goto loop; - } - } - -enter: - do { - s->inp = c; - if (smax >= &w[input_size -1]) - overflo(); - s->nst = ++smax; - s = smax; - } while ((c = getargc()) != '\n' && c != EOF); - if (xflag) { -nenter: - s->inp = '\n'; - if (smax >= &w[input_size -1]) - overflo(); - s->nst = ++smax; - } - smax->out = 1; - s = w; - if (c != EOF) - goto nword; -} - -/* - * This function is an unexpected condition, since input_size should have been - * calculated correctly before hand. - */ - -void -overflo(void) -{ - (void) fprintf(stderr, gettext("fgrep: wordlist too large\n")); - exit(2); -} - -void -cfail(void) -{ - int qsize = QSIZE; - struct words **queue = NULL; - - /* - * front and rear are pointers used to traverse the global words - * structure "w" which contains the data of input pattern file - */ - struct words **front, **rear; - struct words *state; - unsigned long frontoffset = 0, rearoffset = 0; - char c; - struct words *s; - s = w; - if ((queue = (struct words **)calloc(qsize, sizeof (struct words *))) - == NULL) { - perror("fgrep"); - exit(2); - } - front = rear = queue; -init: - if ((s->inp) != 0) { - *rear++ = s->nst; - /* - * Reallocates the queue if the number of distinct starting - * character of patterns exceeds the qsize value - */ - if (rear >= &queue[qsize - 1]) { - frontoffset = front - queue; - rearoffset = rear - queue; - qsize += QSIZE; - if ((queue = (struct words **)realloc(queue, - qsize * sizeof (struct words *))) == NULL) { - perror("fgrep"); - exit(2); - } - front = queue + frontoffset; - rear = queue + rearoffset; - } - } - if ((s = s->link) != 0) { - goto init; - } - - while (rear != front) { - s = *front++; -cloop: - if ((c = s->inp) != 0) { - *rear++ = (q = s->nst); - /* - * Reallocate the queue if the rear pointer reaches the end - * queue - */ - if (rear >= &queue[qsize - 1]) { - frontoffset = front - queue; - rearoffset = rear - queue; - qsize += QSIZE; - if ((queue = (struct words **)realloc(queue, - qsize * sizeof (struct words *))) == NULL) { - perror("fgrep"); - exit(2); - } - front = queue + frontoffset; - rear = queue + rearoffset; - } - state = s->fail; -floop: - if (state == 0) - state = w; - if (state->inp == c) { -qloop: - q->fail = state->nst; - if ((state->nst)->out == 1) - q->out = 1; - if ((q = q->link) != 0) - goto qloop; - } else if ((state = state->link) != 0) - goto floop; - } - if ((s = s->link) != 0) - goto cloop; - } -} - -wchar_t -letter(wchar_t c) -{ - if (c >= 'a' && c <= 'z') - return (c); - if (c >= 'A' && c <= 'Z') - return (c + 'a' - 'A'); - return (c); -} diff --git a/usr/src/cmd/grep_xpg4/Makefile b/usr/src/cmd/grep/Makefile similarity index 73% rename from usr/src/cmd/grep_xpg4/Makefile rename to usr/src/cmd/grep/Makefile index fb7c7d1a58..85d00f57fe 100644 --- a/usr/src/cmd/grep_xpg4/Makefile +++ b/usr/src/cmd/grep/Makefile @@ -25,7 +25,6 @@ # PROG= grep -XPG4PROG= grep FFILE= fgrep EFILE= egrep @@ -34,7 +33,8 @@ include ../Makefile.cmd CERRWARN += -_gcc=-Wno-parentheses CERRWARN += -_gcc=-Wno-uninitialized -ROOTXPG4LINKS = $(ROOTXPG4BIN)/$(FFILE) $(ROOTXPG4BIN)/$(EFILE) +ROOTXPG4LINKS = $(ROOTXPG4BIN)/$(FFILE) $(ROOTXPG4BIN)/$(EFILE) $(ROOTXPG4BIN)/$(PROG) +ROOTLINKS = $(ROOTBIN)/$(FFILE) $(ROOTBIN)/$(EFILE) CFLAGS += $(CCVERBOSE) CPPFLAGS += -D_FILE_OFFSET_BITS=64 @@ -44,26 +44,30 @@ POFILES= grep.po .KEEP_STATE: -all: $(XPG4) +all: $(PROG) -install: all $(ROOTXPG4PROG) $(ROOTXPG4LINKS) +install: all $(ROOTPROG) $(ROOTLINKS) $(ROOTXPG4LINKS) -$(ROOTXPG4LINKS): $(ROOTXPG4PROG) +$(ROOTLINKS): $(ROOTPROG) -$(RM) $@ - -$(LN) $(ROOTXPG4PROG) $@ + -$(LN) $(ROOTPROG) $@ + +$(ROOTXPG4LINKS): $(ROOTPROG) + -$(RM) $@ + -$(SYMLINK) ../../bin/grep $@ $(POFILE): $(POFILES) $(RM) $@ $(CP) $(POFILES) $@ # Make the links locally for test purposes -test: $(FFILE) $(EFILE) +test: $(FFILE) $(EFILE) -$(FFILE): $(XPG4PROG) - @$(RM) $(FFILE); $(LN) $(XPG4PROG) $(FFILE) +$(FFILE): $(PROG) + @$(RM) $(FFILE); $(LN) $(PROG) $(FFILE) -$(EFILE): $(XPG4PROG) - @$(RM) $(EFILE); $(LN) $(XPG4PROG) $(EFILE) +$(EFILE): $(PROG) + @$(RM) $(EFILE); $(LN) $(PROG) $(EFILE) clean: diff --git a/usr/src/cmd/grep_xpg4/grep.c b/usr/src/cmd/grep/grep.c similarity index 100% rename from usr/src/cmd/grep_xpg4/grep.c rename to usr/src/cmd/grep/grep.c diff --git a/usr/src/cmd/grep/grep.xcl b/usr/src/cmd/grep/grep.xcl deleted file mode 100644 index 8133757616..0000000000 --- a/usr/src/cmd/grep/grep.xcl +++ /dev/null @@ -1,28 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -msgid "" -msgid "hblcnsviy" -msgid "%s[-c|-l|-q] [-bhinsv%sx]" -msgid "%s:" -msgid "%ld\n" -msgid "%s\n" -msgid "%ld:" diff --git a/usr/src/cmd/ldap/ns_ldap/idsconfig.sh b/usr/src/cmd/ldap/ns_ldap/idsconfig.sh index 8f36137cc3..4d3df78e42 100644 --- a/usr/src/cmd/ldap/ns_ldap/idsconfig.sh +++ b/usr/src/cmd/ldap/ns_ldap/idsconfig.sh @@ -984,7 +984,7 @@ init() DOM="" # Set to NULL # If DNS domain (resolv.conf) exists use that, otherwise use domainname. if [ -f /etc/resolv.conf ]; then - DOM=`/usr/xpg4/bin/grep -i -E '^domain|^search' /etc/resolv.conf \ + DOM=`/usr/bin/grep -i -E '^domain|^search' /etc/resolv.conf \ | awk '{ print $2 }' | tail -1` fi diff --git a/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh b/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh index d7fe25a511..61dd87bce0 100644 --- a/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh +++ b/usr/src/cmd/sgs/test/ld/x64/tls/ie/x64-ie-test.sh @@ -16,7 +16,7 @@ function grep_test { name=$1 pattern=$2 - if /usr/xpg4/bin/fgrep -q "${pattern}"; then + if /usr/bin/fgrep -q "${pattern}"; then print -u2 "pass: $name" else print -u2 "FAIL: $name" diff --git a/usr/src/cmd/tsol/misc/txzonemgr.sh b/usr/src/cmd/tsol/misc/txzonemgr.sh index 179a0e8170..47ac3cc425 100644 --- a/usr/src/cmd/tsol/misc/txzonemgr.sh +++ b/usr/src/cmd/tsol/misc/txzonemgr.sh @@ -1415,7 +1415,7 @@ tearDownZones() { gettext "OK to destroy all zones [y|N]? " read ans printf "%s\n" "$ans" \ - | /usr/xpg4/bin/grep -Eq "$(locale yesexpr)" + | /usr/bin/grep -Eq "$(locale yesexpr)" if [ $? -ne 0 ] ; then gettext "canceled.\n" return 1 diff --git a/usr/src/lib/libsaveargs/tests/functional/test.sh b/usr/src/lib/libsaveargs/tests/functional/test.sh index dea1059b2c..e4a8e2688a 100644 --- a/usr/src/lib/libsaveargs/tests/functional/test.sh +++ b/usr/src/lib/libsaveargs/tests/functional/test.sh @@ -20,7 +20,7 @@ function tester { ./$prog >/dev/null & pid=$! - if (/usr/bin/amd64/pstack $pid | /usr/xpg4/bin/grep -q "${pattern}"); then + if (/usr/bin/amd64/pstack $pid | /usr/bin/grep -q "${pattern}"); then echo "pass: ${prog}" else echo "FAIL: ${prog}" diff --git a/usr/src/lib/libshell/common/tests/sun_solaris_cr_6887363_shell_sometimes_mishandles_return_value_of_its_child_process.sh b/usr/src/lib/libshell/common/tests/sun_solaris_cr_6887363_shell_sometimes_mishandles_return_value_of_its_child_process.sh index f302f6379e..93e559c0a7 100644 --- a/usr/src/lib/libshell/common/tests/sun_solaris_cr_6887363_shell_sometimes_mishandles_return_value_of_its_child_process.sh +++ b/usr/src/lib/libshell/common/tests/sun_solaris_cr_6887363_shell_sometimes_mishandles_return_value_of_its_child_process.sh @@ -172,7 +172,7 @@ out="$(unset VMALLOC_OPTIONS VMDEBUG ; cat_test | ${SHELL} 2>&1)" || err_exit "U [[ "${out}" != "" ]] || err_exit "No output from test" # filter output and check it -out2="$(/usr/xpg4/bin/egrep -v '^((read-seq|read-rand|syncread-seq|syncread-seq)[[:space:][:blank:]]*)*$' <<<"${out}")" +out2="$(/usr/bin/egrep -v '^((read-seq|read-rand|syncread-seq|syncread-seq)[[:space:][:blank:]]*)*$' <<<"${out}")" [[ "${out2}" == "" ]] || err_exit "Unexpected output '${out2}'" diff --git a/usr/src/lib/libshell/misc/shell_styleguide.docbook b/usr/src/lib/libshell/misc/shell_styleguide.docbook index 0376912d1f..74bc7501b5 100644 --- a/usr/src/lib/libshell/misc/shell_styleguide.docbook +++ b/usr/src/lib/libshell/misc/shell_styleguide.docbook @@ -352,9 +352,9 @@ done At least print - /usr/bin/fgrep/usr/xpg4/bin/fgrep - /usr/bin/grep /usr/xpg4/bin/grep - /usr/bin/egrep/usr/xpg4/bin/egrep + /usr/bin/fgrep + /usr/bin/grep + /usr/bin/egrep support -- as "end of arguments"-terminator. diff --git a/usr/src/man/man1/egrep.1 b/usr/src/man/man1/egrep.1 index 9fdf321590..b3d8d2ca96 100644 --- a/usr/src/man/man1/egrep.1 +++ b/usr/src/man/man1/egrep.1 @@ -9,44 +9,28 @@ .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH EGREP 1 "May 3, 2013" +.TH EGREP 1 "Nov 28, 2017" .SH NAME egrep \- search a file for a pattern using full regular expressions .SH SYNOPSIS .LP .nf -\fB/usr/bin/egrep\fR [\fB-bcHhilnqsv\fR] \fB-e\fR \fIpattern_list\fR [\fIfile...\fR] -.fi - -.LP -.nf -\fB/usr/bin/egrep\fR [\fB-bcHhilnqsv\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR] -.fi - -.LP -.nf -\fB/usr/bin/egrep\fR [\fB-bcHhilnqsv\fR] \fIpattern\fR [\fIfile...\fR] -.fi - -.LP -.nf -\fB/usr/xpg4/bin/egrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR] +\fB/usr/bin/egrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR] [\fIfile...\fR] .fi .LP .nf -\fB/usr/xpg4/bin/egrep\fR [\fB-bcHhilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR +\fB/usr/bin/egrep\fR [\fB-bcHhilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR] .fi .LP .nf -\fB/usr/xpg4/bin/egrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR] +\fB/usr/bin/egrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR] .fi .SH DESCRIPTION -.sp .LP The \fBegrep\fR (\fIexpression grep\fR) utility searches files for a pattern of characters and prints all lines that contain that pattern. \fBegrep\fR uses @@ -58,37 +42,9 @@ fast deterministic algorithm that sometimes needs exponential space. If no files are specified, \fBegrep\fR assumes standard input. Normally, each line found is copied to the standard output. The file name is printed before each line found if there is more than one input file. -.SS "/usr/bin/egrep" -.sp .LP -The \fB/usr/bin/egrep\fR utility accepts full regular expressions as described -on the \fBregexp\fR(5) manual page, except for \fB\e(\fR and \fB\e)\fR, -\fB\e(\fR and \fB\e)\fR, \fB\e{\fR and \fB\e}\fR, \fB\e<\fR and \fB\e>\fR, and -\fB\en\fR, and with the addition of: -.RS +4 -.TP -1. -A full regular expression followed by \fB+\fR that matches one or more -occurrences of the full regular expression. -.RE -.RS +4 -.TP -2. -A full regular expression followed by \fB?\fR that matches 0 or 1 -occurrences of the full regular expression. -.RE -.RS +4 -.TP -3. -Full regular expressions separated by | or by a \fBNEWLINE\fR that match -strings that are matched by any of the expressions. -.RE -.RS +4 -.TP -4. -A full regular expression that can be enclosed in parentheses \fB()\fRfor -grouping. -.RE +The \fBegrep\fR utility accepts the same form of full regular expressions as +\fBgrep\fR(1) -E option. .sp .LP Be careful using the characters \fB$\fR, \fB*\fR, \fB[\fR, \fB^\fR, |, \fB(\fR, @@ -99,23 +55,15 @@ expression\fR in single quotes (\fBa\'\fR\fBa\'\fR). .LP The order of precedence of operators is \fB[\|]\fR, then \fB*\|?\|+\fR, then concatenation, then | and NEWLINE. -.SS "/usr/xpg4/bin/egrep" -.sp -.LP -The \fB/usr/xpg4/bin/egrep\fR utility uses the regular expressions described in -the \fBEXTENDED REGULAR EXPRESSIONS\fR section of the \fBregex\fR(5) manual -page. .SH OPTIONS -.sp .LP -The following options are supported for both \fB/usr/bin/egrep\fR and -\fB/usr/xpg4/bin/egrep\fR: +The following options are supported: .sp .ne 2 .na \fB\fB-b\fR\fR .ad -.RS 19n +.RS 6n Precede each line by the block number on which it was found. This can be useful in locating block numbers by context (first block is 0). .RE @@ -125,7 +73,7 @@ in locating block numbers by context (first block is 0). .na \fB\fB-c\fR\fR .ad -.RS 19n +.RS 6n Print only a count of the lines that contain the pattern. .RE @@ -134,7 +82,7 @@ Print only a count of the lines that contain the pattern. .na \fB\fB-e\fR \fIpattern_list\fR\fR .ad -.RS 19n +.RS 6n Search for a \fIpattern_list\fR (\fIfull regular expression\fR that begins with a \fB\(mi\fR). .RE @@ -144,7 +92,7 @@ a \fB\(mi\fR). .na \fB\fB-f\fR \fIfile\fR\fR .ad -.RS 19n +.RS 6n Take the list of \fIfull\fR \fIregular\fR \fIexpressions\fR from \fIfile\fR. .RE @@ -153,7 +101,7 @@ Take the list of \fIfull\fR \fIregular\fR \fIexpressions\fR from \fIfile\fR. .na \fB\fB-H\fR\fR .ad -.RS 19n +.RS 6n Precedes each line by the name of the file containing the matching line. .RE @@ -162,7 +110,7 @@ Precedes each line by the name of the file containing the matching line. .na \fB\fB-h\fR\fR .ad -.RS 19n +.RS 6n Suppress printing of filenames when searching multiple files. .RE @@ -171,7 +119,7 @@ Suppress printing of filenames when searching multiple files. .na \fB\fB-i\fR\fR .ad -.RS 19n +.RS 6n Ignore upper/lower case distinction during comparisons. .RE @@ -180,7 +128,7 @@ Ignore upper/lower case distinction during comparisons. .na \fB\fB-l\fR\fR .ad -.RS 19n +.RS 6n Print the names of files with matching lines once, separated by NEWLINEs. Does not repeat the names of files when the pattern is found more than once. .RE @@ -190,7 +138,7 @@ not repeat the names of files when the pattern is found more than once. .na \fB\fB-n\fR\fR .ad -.RS 19n +.RS 6n Precede each line by its line number in the file (first line is 1). .RE @@ -199,7 +147,7 @@ Precede each line by its line number in the file (first line is 1). .na \fB\fB-q\fR\fR .ad -.RS 19n +.RS 6n Quiet. Does not write anything to the standard output, regardless of matching lines. Exits with zero status if an input line is selected. .RE @@ -209,7 +157,7 @@ lines. Exits with zero status if an input line is selected. .na \fB\fB-s\fR\fR .ad -.RS 19n +.RS 6n Legacy equivalent of \fB-q\fR. .RE @@ -218,14 +166,10 @@ Legacy equivalent of \fB-q\fR. .na \fB\fB-v\fR\fR .ad -.RS 19n +.RS 6n Print all lines except those that contain the pattern. .RE -.SS "/usr/xpg4/bin/egrep" -.sp -.LP -The following options are supported for \fB/usr/xpg4/bin/egrep\fR only: .sp .ne 2 .na @@ -237,7 +181,6 @@ entire fixed string or regular expression to be matching lines. .RE .SH OPERANDS -.sp .LP The following operands are supported: .sp @@ -250,40 +193,25 @@ A path name of a file to be searched for the patterns. If no \fIfile\fR operands are specified, the standard input is used. .RE -.SS "/usr/bin/egrep" -.sp -.ne 2 -.na -\fB\fIpattern\fR\fR -.ad -.RS 11n -Specify a pattern to be used during the search for input. -.RE - -.SS "/usr/xpg4/bin/egrep" -.sp .ne 2 .na \fB\fIpattern\fR\fR .ad -.RS 11n +.RS 8n Specify one or more patterns to be used during the search for input. This -operand is treated as if it were specified as \fB-e\fR\fIpattern_list.\fR. +operand is treated as if it were specified as \fB-e\fR\fIpattern_list\fR. .RE .SH USAGE -.sp .LP See \fBlargefile\fR(5) for the description of the behavior of \fBegrep\fR when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). .SH ENVIRONMENT VARIABLES -.sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBegrep\fR: \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. .SH EXIT STATUS -.sp .LP The following exit values are returned: .sp @@ -314,24 +242,8 @@ For syntax errors or inaccessible files (even if matches were found). .RE .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: -.SS "/usr/bin/egrep" -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -CSI Not Enabled -.TE - -.SS "/usr/xpg4/bin/egrep" -.sp .sp .TS @@ -344,22 +256,22 @@ CSI Enabled .TE .SH SEE ALSO -.sp .LP \fBfgrep\fR(1), \fBgrep\fR(1), \fBsed\fR(1), \fBsh\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBregex\fR(5), \fBregexp\fR(5), \fBXPG4\fR(5) .SH NOTES -.sp .LP Ideally there should be only one \fBgrep\fR command, but there is not a single algorithm that spans a wide enough range of space-time trade-offs. .sp .LP Lines are limited only by the size of the available virtual memory. -.SS "/usr/xpg4/bin/egrep" -.sp .LP -The \fB/usr/xpg4/bin/egrep\fR utility is identical to \fB/usr/xpg4/bin/grep\fR +The \fB/usr/bin/egrep\fR utility is identical to \fB/usr/bin/grep\fR \fB-E\fR. See \fBgrep\fR(1). Portable applications should use -\fB/usr/xpg4/bin/grep\fR \fB-E\fR. +\fB/usr/bin/grep\fR \fB-E\fR. +.LP +In the past the behavior of \fB/usr/xpg4/bin/egrep\fR and +\fB/usr/bin/egrep\fR utilities was different. Now \fB/usr/bin/egrep\fR +is replaced by \fB/usr/xpg4/bin/egrep\fR. diff --git a/usr/src/man/man1/fgrep.1 b/usr/src/man/man1/fgrep.1 index 7c254b67ff..3bf3b724e5 100644 --- a/usr/src/man/man1/fgrep.1 +++ b/usr/src/man/man1/fgrep.1 @@ -9,44 +9,28 @@ .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH FGREP 1 "May 3, 2013" +.TH FGREP 1 "Nov 28, 2017" .SH NAME fgrep \- search a file for a fixed-character string .SH SYNOPSIS .LP .nf -\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fIfile...\fR] -.fi - -.LP -.nf -\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR] -.fi - -.LP -.nf -\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR] -.fi - -.LP -.nf -\fB/usr/xpg4/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR] +\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR] [\fIfile...\fR] .fi .LP .nf -\fB/usr/xpg4/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR +\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR] .fi .LP .nf -\fB/usr/xpg4/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR] +\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR] .fi .SH DESCRIPTION -.sp .LP The \fBfgrep\fR (fast \fBgrep\fR) utility searches files for a character string and prints all lines that contain that string. \fBfgrep\fR is different from @@ -66,16 +50,14 @@ If no files are specified, \fBfgrep\fR assumes standard input. Normally, each line that is found is copied to the standard output. The file name is printed before each line that is found if there is more than one input file. .SH OPTIONS -.sp .LP -The following options are supported for both \fB/usr/bin/fgrep\fR and -\fB/usr/xpg4/bin/fgrep\fR: +The following options are supported: .sp .ne 2 .na \fB\fB-b\fR\fR .ad -.RS 19n +.RS 6n Precedes each line by the block number on which the line was found. This can be useful in locating block numbers by context. The first block is 0. .RE @@ -85,7 +67,7 @@ useful in locating block numbers by context. The first block is 0. .na \fB\fB-c\fR\fR .ad -.RS 19n +.RS 6n Prints only a count of the lines that contain the pattern. .RE @@ -94,7 +76,7 @@ Prints only a count of the lines that contain the pattern. .na \fB\fB-e\fR \fIpattern_list\fR\fR .ad -.RS 19n +.RS 6n Searches for a \fIstring\fR in \fIpattern-list\fR. This is useful when the \fIstring\fR begins with a \fB\(mi\fR\&. .RE @@ -104,7 +86,7 @@ Searches for a \fIstring\fR in \fIpattern-list\fR. This is useful when the .na \fB\fB-f\fR \fIpattern-file\fR\fR .ad -.RS 19n +.RS 6n Takes the list of patterns from \fIpattern-file\fR. .RE @@ -113,7 +95,7 @@ Takes the list of patterns from \fIpattern-file\fR. .na \fB\fB-H\fR\fR .ad -.RS 19n +.RS 6n Precedes each line by the name of the file containing the matching line. .RE @@ -122,7 +104,7 @@ Precedes each line by the name of the file containing the matching line. .na \fB\fB-h\fR\fR .ad -.RS 19n +.RS 6n Suppresses printing of files when searching multiple files. .RE @@ -131,7 +113,7 @@ Suppresses printing of files when searching multiple files. .na \fB\fB-i\fR\fR .ad -.RS 19n +.RS 6n Ignores upper/lower case distinction during comparisons. .RE @@ -140,7 +122,7 @@ Ignores upper/lower case distinction during comparisons. .na \fB\fB-l\fR\fR .ad -.RS 19n +.RS 6n Prints the names of files with matching lines once, separated by new-lines. Does not repeat the names of files when the pattern is found more than once. .RE @@ -150,7 +132,7 @@ Does not repeat the names of files when the pattern is found more than once. .na \fB\fB-n\fR\fR .ad -.RS 19n +.RS 6n Precedes each line by its line number in the file. The first line is 1. .RE @@ -159,7 +141,7 @@ Precedes each line by its line number in the file. The first line is 1. .na \fB\fB-q\fR\fR .ad -.RS 19n +.RS 6n Quiet. Does not write anything to the standard output, regardless of matching lines. Exits with zero status if an input line is selected. .RE @@ -169,7 +151,7 @@ lines. Exits with zero status if an input line is selected. .na \fB\fB-s\fR\fR .ad -.RS 19n +.RS 6n Legacy equivalent of \fB-q\fR. .RE @@ -178,7 +160,7 @@ Legacy equivalent of \fB-q\fR. .na \fB\fB-v\fR\fR .ad -.RS 19n +.RS 6n Prints all lines except those that contain the pattern. .RE @@ -187,12 +169,11 @@ Prints all lines except those that contain the pattern. .na \fB\fB-x\fR\fR .ad -.RS 19n +.RS 6n Prints only lines that are matched entirely. .RE .SH OPERANDS -.sp .LP The following operands are supported: .sp @@ -205,40 +186,25 @@ Specifies a path name of a file to be searched for the patterns. If no \fIfile\fR operands are specified, the standard input will be used. .RE -.SS "/usr/bin/fgrep" -.sp -.ne 2 -.na -\fB\fIpattern\fR\fR -.ad -.RS 11n -Specifies a pattern to be used during the search for input. -.RE - -.SS "/usr/xpg4/bin/fgrep" -.sp .ne 2 .na \fB\fIpattern\fR\fR .ad -.RS 11n +.RS 8n Specifies one or more patterns to be used during the search for input. This operand is treated as if it were specified as \fB-e\fR \fIpattern_list\fR. .RE .SH USAGE -.sp .LP See \fBlargefile\fR(5) for the description of the behavior of \fBfgrep\fR when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). .SH ENVIRONMENT VARIABLES -.sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBfgrep\fR: \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. .SH EXIT STATUS -.sp .LP The following exit values are returned: .sp @@ -268,11 +234,7 @@ If no matches are found For syntax errors or inaccessible files, even if matches were found. .RE -.SS "/usr/xpg4/bin/fgrep" -.sp - .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -286,21 +248,21 @@ CSI Enabled .TE .SH SEE ALSO -.sp .LP \fBed\fR(1), \fBegrep\fR(1), \fBgrep\fR(1), \fBsed\fR(1), \fBsh\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBXPG4\fR(5) .SH NOTES -.sp .LP Ideally, there should be only one \fBgrep\fR command, but there is not a single algorithm that spans a wide enough range of space-time tradeoffs. .sp .LP Lines are limited only by the size of the available virtual memory. -.SS "/usr/xpg4/bin/fgrep" -.sp .LP -The \fB/usr/xpg4/bin/fgrep\fR utility is identical to \fB/usr/xpg4/bin/grep\fR +The \fB/usr/bin/fgrep\fR utility is identical to \fB/usr/bin/grep\fR \fB-F\fR (see \fBgrep\fR(1)). Portable applications should use -\fB/usr/xpg4/bin/grep\fR \fB-F\fR. +\fB/usr/bin/grep\fR \fB-F\fR. +.LP +In the past the behavior of \fB/usr/xpg4/bin/fgrep\fR and +\fB/usr/bin/fgrep\fR utilities was different. Now \fB/usr/bin/fgrep\fR +is replaced by \fB/usr/xpg4/bin/fgrep\fR. diff --git a/usr/src/man/man1/grep.1 b/usr/src/man/man1/grep.1 index f3e3402269..0b663de61b 100644 --- a/usr/src/man/man1/grep.1 +++ b/usr/src/man/man1/grep.1 @@ -10,33 +10,27 @@ .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH GREP 1 "June 5, 2017" +.TH GREP 1 "Nov 28, 2017" .SH NAME grep \- search a file for a pattern .SH SYNOPSIS .LP .nf -\fB/usr/bin/grep\fR [\fB-c\fR | \fB-l\fR |\fB-q\fR] [\fB-r\fR | \fB-R\fR] [\fB-bHhinsvw\fR] - \fIlimited-regular-expression\fR [\fIfilename\fR]... -.fi - -.LP -.nf -\fB/usr/xpg4/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR] +\fB/usr/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR] [\fB-bHhinsvwx\fR] [\fB-A\fR \fInumber\fR] [\fB-B\fR \fInumber\fR] [\fB-C\fR \fInumber\fR | \fB-\fR\fInumber\fR] \fB-e\fR \fIpattern_list\fR... [\fB-f\fR \fIpattern_file\fR]... [\fIfile\fR]... .fi .LP .nf -\fB/usr/xpg4/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR] +\fB/usr/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR] [\fB-bHhinsvwx\fR] [\fB-A\fR \fInumber\fR] [\fB-B\fR \fInumber\fR] [\fB-C\fR \fInumber\fR | \fB-\fR\fInumber\fR] [\fB-e\fR \fIpattern_list\fR]... \fB-f\fR \fIpattern_file\fR... [\fIfile\fR]... .fi .LP .nf -\fB/usr/xpg4/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR] +\fB/usr/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR] [\fB-bHhinsvwx\fR] [\fB-A\fR \fInumber\fR] [\fB-B\fR \fInumber\fR] [\fB-C\fR \fInumber\fR | \fB-\fR\fInumber\fR] \fIpattern\fR [\fIfile\fR]... .fi @@ -55,23 +49,28 @@ in single quotes \fB\'\fR\&...\fB\'\fR\&. If no files are specified, \fBgrep\fR assumes standard input. Normally, each line found is copied to standard output. The file name is printed before each line found if there is more than one input file. -.SS "/usr/bin/grep" .LP -The \fB/usr/bin/grep\fR utility uses limited regular expressions like those -described on the \fBregexp\fR(5) manual page to match the patterns. -.SS "/usr/xpg4/bin/grep" -.LP -The options \fB-E\fR and \fB-F\fR affect the way \fB/usr/xpg4/bin/grep\fR +The options \fB-E\fR and \fB-F\fR affect the way \fBgrep\fR interprets \fIpattern_list\fR. If \fB-E\fR is specified, -\fB/usr/xpg4/bin/grep\fR interprets \fIpattern_list\fR as a full regular +\fBgrep\fR interprets \fIpattern_list\fR as a full regular expression (see \fB-E\fR for description). If \fB-F\fR is specified, \fBgrep\fR interprets \fIpattern_list\fR as a fixed string. If neither are specified, \fBgrep\fR interprets \fIpattern_list\fR as a basic regular expression as described on \fBregex\fR(5) manual page. .SH OPTIONS .LP -The following options are supported for both \fB/usr/bin/grep\fR and -\fB/usr/xpg4/bin/grep\fR: +The following options are supported: +.sp +.ne 2 +.na +\fB\fB-A\fR \fInumber\fR\fR +.ad +.RS 6n +Prints \fInumber\fR input lines of context after each matching line. If there +are multiple matching lines, their context lines are separated by a \fB--\fR +delimiter line. +.RE + .sp .ne 2 .na @@ -85,141 +84,179 @@ useful in locating block numbers by context (first block is 0). .sp .ne 2 .na -\fB\fB-c\fR\fR +\fB\fB-B\fR \fInumber\fR\fR .ad .RS 6n -Prints only a count of the lines that contain the pattern. +Prints \fInumber\fR input lines of context before each matching line. If there +are multiple matching lines, their context lines are separated by a \fB--\fR +delimiter line. .RE .sp .ne 2 .na -\fB\fB-H\fR\fR +\fB\fB-c\fR\fR .ad .RS 6n -Precedes each line by the name of the file containing the matching line. +Prints only a count of the lines that contain the pattern. .RE .sp .ne 2 .na -\fB\fB-h\fR\fR +\fB\fB-H\fR\fR .ad .RS 6n -Prevents the name of the file containing the matching line from being prepended -to that line. Used when searching multiple files. +Precedes each line by the name of the file containing the matching line. .RE .sp .ne 2 .na -\fB\fB-i\fR\fR +\fB\fB-e\fR \fIpattern_list\fR\fR .ad .RS 6n -Ignores upper/lower case distinction during comparisons. +Specifies one or more patterns to be used during the search for input. Patterns +in \fIpattern_list\fR must be separated by a NEWLINE character. A null pattern +can be specified by two adjacent newline characters in \fIpattern_list\fR. +Unless the \fB-E\fR or \fB-F\fR option is also specified, each pattern is +treated as a basic regular expression. Multiple \fB-e\fR and \fB-f\fR options +are accepted by \fBgrep\fR. All of the specified patterns are used when +matching lines, but the order of evaluation is unspecified. .RE .sp .ne 2 .na -\fB\fB-l\fR\fR +\fB\fB-E\fR\fR .ad .RS 6n -Prints only the names of files with matching lines, separated by NEWLINE -characters. Does not repeat the names of files when the pattern is found more -than once. +Matches using full regular expressions. Treats each pattern specified as a full +regular expression. If any entire full regular expression pattern matches an +input line, the line is matched. A null full regular expression matches every +line. Each pattern is interpreted as a full regular expression as described on +the \fBregex\fR(5) manual page, except for \fB\e(\fR and \fB\e)\fR, and +including: +.RS +4 +.TP +1. +A full regular expression followed by \fB+\fR that matches one or more +occurrences of the full regular expression. +.RE +.RS +4 +.TP +2. +A full regular expression followed by \fB?\fR that matches 0 or 1 +occurrences of the full regular expression. +.RE +.RS +4 +.TP +3. +Full regular expressions separated by | or by a new-line that match strings +that are matched by any of the expressions. +.RE +.RS +4 +.TP +4. +A full regular expression that is enclosed in parentheses \fB()\fR for +grouping. +.RE +The order of precedence of operators is \fB[\|]\fR, then \fB*\|?\|+\fR, then +concatenation, then | and new-line. .RE .sp .ne 2 .na -\fB\fB-n\fR\fR +\fB\fB-f\fR \fIpattern_file\fR\fR .ad .RS 6n -Precedes each line by its line number in the file (first line is 1). +Reads one or more patterns from the file named by the path name +\fIpattern_file\fR. Patterns in \fIpattern_file\fR are terminated by a NEWLINE +character. A null pattern can be specified by an empty line in +\fIpattern_file\fR. Unless the \fB-E\fR or \fB-F\fR option is also specified, +each pattern is treated as a basic regular expression. .RE .sp .ne 2 .na -\fB\fB-r\fR\fR +\fB\fB-F\fR\fR .ad .RS 6n -Read all files under each directory, recursively. Follow symbolic links on -the command line, but skip symlinks that are encountered recursively. If file -is a device, FIFO, or socket, skip it. +Matches using fixed strings. Treats each pattern specified as a string instead +of a regular expression. If an input line contains any of the patterns as a +contiguous sequence of bytes, the line is matched. A null string matches every +line. See \fBfgrep\fR(1) for more information. .RE .sp .ne 2 .na -\fB\fB-R\fR\fR +\fB\fB-h\fR\fR .ad .RS 6n -Read all files under each directory, recursively, following all symbolic links. +Prevents the name of the file containing the matching line from being prepended +to that line. Used when searching multiple files. .RE .sp .ne 2 .na -\fB\fB-q\fR\fR +\fB\fB-i\fR\fR .ad .RS 6n -Quiet. Does not write anything to the standard output, regardless of matching -lines. Exits with zero status if an input line is selected. +Ignores upper/lower case distinction during comparisons. .RE .sp .ne 2 .na -\fB\fB-s\fR\fR +\fB\fB-l\fR\fR .ad .RS 6n -Suppresses error messages about nonexistent or unreadable files. +Prints only the names of files with matching lines, separated by NEWLINE +characters. Does not repeat the names of files when the pattern is found more +than once. .RE .sp .ne 2 .na -\fB\fB-v\fR\fR +\fB\fB-n\fR\fR .ad .RS 6n -Prints all lines except those that contain the pattern. +Precedes each line by its line number in the file (first line is 1). .RE .sp .ne 2 .na -\fB\fB-w\fR\fR +\fB\fB-r\fR\fR .ad .RS 6n -Searches for the expression as a word as if surrounded by \fB\e<\fR and -\fB\e>\fR\&. +Read all files under each directory, recursively. Follow symbolic links on +the command line, but skip symlinks that are encountered recursively. If file +is a device, FIFO, or socket, skip it. .RE -.SS "/usr/xpg4/bin/grep" -.LP -The following options are supported for \fB/usr/xpg4/bin/grep\fR only: .sp .ne 2 .na -\fB\fB-A\fR \fInumber\fR\fR +\fB\fB-R\fR\fR .ad -.RS 19n -Prints \fInumber\fR input lines of context after each matching line. If there -are multiple matching lines, their context lines are separated by a \fB--\fR -delimiter line. +.RS 6n +Read all files under each directory, recursively, following all symbolic links. .RE .sp .ne 2 .na -\fB\fB-B\fR \fInumber\fR\fR +\fB\fB-q\fR\fR .ad -.RS 19n -Prints \fInumber\fR input lines of context before each matching line. If there -are multiple matching lines, their context lines are separated by a \fB--\fR -delimiter line. +.RS 6n +Quiet. Does not write anything to the standard output, regardless of matching +lines. Exits with zero status if an input line is selected. .RE .sp @@ -231,91 +268,38 @@ delimiter line. .na \fB\fB-C\fR \fInumber\fR\fR .ad -.RS 19n +.RS 6n Prints \fInumber\fR input lines of context before and \fInumber\fR input lines of context after each matching line. If there are multiple matching lines, their context lines are separated by a \fB--\fR delimiter line. .RE - .sp .ne 2 .na -\fB\fB-e\fR \fIpattern_list\fR\fR -.ad -.RS 19n -Specifies one or more patterns to be used during the search for input. Patterns -in \fIpattern_list\fR must be separated by a NEWLINE character. A null pattern -can be specified by two adjacent newline characters in \fIpattern_list\fR. -Unless the \fB-E\fR or \fB-F\fR option is also specified, each pattern is -treated as a basic regular expression. Multiple \fB-e\fR and \fB-f\fR options -are accepted by \fBgrep\fR. All of the specified patterns are used when -matching lines, but the order of evaluation is unspecified. -.RE - -.sp -.ne 2 -.na -\fB\fB-E\fR\fR +\fB\fB-s\fR\fR .ad -.RS 19n -Matches using full regular expressions. Treats each pattern specified as a full -regular expression. If any entire full regular expression pattern matches an -input line, the line is matched. A null full regular expression matches every -line. Each pattern is interpreted as a full regular expression as described on -the \fBregex\fR(5) manual page, except for \fB\e(\fR and \fB\e)\fR, and -including: -.RS +4 -.TP -1. -A full regular expression followed by \fB+\fR that matches one or more -occurrences of the full regular expression. -.RE -.RS +4 -.TP -2. -A full regular expression followed by \fB?\fR that matches 0 or 1 -occurrences of the full regular expression. -.RE -.RS +4 -.TP -3. -Full regular expressions separated by | or by a new-line that match strings -that are matched by any of the expressions. -.RE -.RS +4 -.TP -4. -A full regular expression that is enclosed in parentheses \fB()\fR for -grouping. -.RE -The order of precedence of operators is \fB[\|]\fR, then \fB*\|?\|+\fR, then -concatenation, then | and new-line. +.RS 6n +Suppresses error messages about nonexistent or unreadable files. .RE .sp .ne 2 .na -\fB\fB-f\fR \fIpattern_file\fR\fR +\fB\fB-v\fR\fR .ad -.RS 19n -Reads one or more patterns from the file named by the path name -\fIpattern_file\fR. Patterns in \fIpattern_file\fR are terminated by a NEWLINE -character. A null pattern can be specified by an empty line in -\fIpattern_file\fR. Unless the \fB-E\fR or \fB-F\fR option is also specified, -each pattern is treated as a basic regular expression. +.RS 6n +Prints all lines except those that contain the pattern. .RE .sp .ne 2 .na -\fB\fB-F\fR\fR +\fB\fB-w\fR\fR .ad -.RS 19n -Matches using fixed strings. Treats each pattern specified as a string instead -of a regular expression. If an input line contains any of the patterns as a -contiguous sequence of bytes, the line is matched. A null string matches every -line. See \fBfgrep\fR(1) for more information. +.RS 6n +Searches for the expression as a word as if surrounded by \fB\e<\fR and +\fB\e>\fR\&. .RE .sp @@ -323,7 +307,7 @@ line. See \fBfgrep\fR(1) for more information. .na \fB\fB-x\fR\fR .ad -.RS 19n +.RS 6n Considers only input lines that use all characters in the line to match an entire fixed string or regular expression to be matching lines. .RE @@ -341,21 +325,11 @@ A path name of a file to be searched for the patterns. If no \fIfile\fR operands are specified, the standard input is used. .RE -.SS "/usr/bin/grep" -.ne 2 -.na -\fB\fIpattern\fR\fR -.ad -.RS 11n -Specifies a pattern to be used during the search for input. -.RE - -.SS "/usr/xpg4/bin/grep" .ne 2 .na \fB\fIpattern\fR\fR .ad -.RS 11n +.RS 8n Specifies one or more patterns to be used during the search for input. This operand is treated as if it were specified as \fB-e\fR \fIpattern_list\fR. .RE @@ -437,22 +411,22 @@ All of the following commands print all lines containing strings \fBabc\fR or .sp .in +2 .nf -example% \fB/usr/xpg4/bin/grep 'abc +example% \fB/usr/bin/grep 'abc def'\fR -example% \fB/usr/xpg4/bin/grep -e 'abc +example% \fB/usr/bin/grep -e 'abc def'\fR -example% \fB/usr/xpg4/bin/grep -e 'abc' -e 'def'\fR -example% \fB/usr/xpg4/bin/grep -E 'abc|def'\fR -example% \fB/usr/xpg4/bin/grep -E -e 'abc|def'\fR -example% \fB/usr/xpg4/bin/grep -E -e 'abc' -e 'def'\fR -example% \fB/usr/xpg4/bin/grep -E 'abc +example% \fB/usr/bin/grep -e 'abc' -e 'def'\fR +example% \fB/usr/bin/grep -E 'abc|def'\fR +example% \fB/usr/bin/grep -E -e 'abc|def'\fR +example% \fB/usr/bin/grep -E -e 'abc' -e 'def'\fR +example% \fB/usr/bin/grep -E 'abc def'\fR -example% \fB/usr/xpg4/bin/grep -E -e 'abc +example% \fB/usr/bin/grep -E -e 'abc def'\fR -example% \fB/usr/xpg4/bin/grep -F -e 'abc' -e 'def'\fR -example% \fB/usr/xpg4/bin/grep -F 'abc +example% \fB/usr/bin/grep -F -e 'abc' -e 'def'\fR +example% \fB/usr/bin/grep -F 'abc def'\fR -example% \fB/usr/xpg4/bin/grep -F -e 'abc +example% \fB/usr/bin/grep -F -e 'abc def'\fR .fi .in -2 @@ -468,8 +442,10 @@ Both of the following commands print all lines matching exactly \fBabc\fR or .sp .in +2 .nf -example% \fB/usr/xpg4/bin/grep -E '^abc$ ^def$'\fR -example% \fB/usr/xpg4/bin/grep -F -x 'abc def'\fR +example% \fB/usr/bin/grep -E '^abc$ +^def$'\fR +example% \fB/usr/bin/grep -F -x 'abc +def'\fR .fi .in -2 .sp @@ -512,18 +488,6 @@ Syntax errors or inaccessible files (even if matches were found). .SH ATTRIBUTES .LP See \fBattributes\fR(5) for descriptions of the following attributes: -.SS "/usr/bin/grep" - -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -CSI Not Enabled -.TE - -.SS "/usr/xpg4/bin/grep" .TS box; @@ -544,13 +508,11 @@ Standard See \fBstandards\fR(5). \fBenviron\fR(5), \fBlargefile\fR(5), \fBregex\fR(5), \fBregexp\fR(5), \fBstandards\fR(5) .SH NOTES -.SS "/usr/bin/grep" -.LP -Lines are limited only by the size of the available virtual memory. If there is -a line with embedded nulls, \fBgrep\fR only matches up to the first null. If -the line matches, the entire line is printed. -.SS "/usr/xpg4/bin/grep" .LP The results are unspecified if input files contain lines longer than \fBLINE_MAX\fR bytes or contain binary data. \fBLINE_MAX\fR is defined in \fB/usr/include/limits.h\fR. +.LP +In the past the behavior of \fB/usr/xpg4/bin/grep\fR and +\fB/usr/bin/grep\fR utilities was different. Now \fB/usr/bin/grep\fR +is replaced by \fB/usr/xpg4/bin/grep\fR. diff --git a/usr/src/man/man1/locale.1 b/usr/src/man/man1/locale.1 index 3230020206..d522854c50 100644 --- a/usr/src/man/man1/locale.1 +++ b/usr/src/man/man1/locale.1 @@ -7,7 +7,7 @@ .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH LOCALE 1 "Dec 20, 1996" +.TH LOCALE 1 "Nov 28, 2017" .SH NAME locale \- get locale-specific information .SH SYNOPSIS @@ -22,7 +22,6 @@ locale \- get locale-specific information .fi .SH DESCRIPTION -.sp .LP The \fBlocale\fR utility writes information about the current locale environment, or all public locales, to the standard output. For the purposes of @@ -52,7 +51,6 @@ Specifying a category name selects the named category and all keywords in that category. .RE .SH OPTIONS -.sp .LP The following options are supported: .sp @@ -97,7 +95,6 @@ Writes names of available charmaps; see \fBlocaledef\fR(1). .RE .SH OPERANDS -.sp .LP The following operand is supported: .sp @@ -182,7 +179,7 @@ a user-supplied response is affirmative: .sp .in +2 .nf -\fBif printf "%s\en" "$response" | /usr/xpg4/bin/grep -Eq\e +\fBif printf "%s\en" "$response" | /usr/bin/grep -Eq\e "$(locale yesexpr)" then affirmative processing goes here @@ -194,7 +191,6 @@ fi\fR .sp .SH ENVIRONMENT VARIABLES -.sp .LP See \fBenviron\fR(5) for the descriptions of \fBLANG\fR, \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. @@ -204,7 +200,6 @@ The \fBLANG\fR, \fBLC_*\fR, and \fBNLSPATH\fR environment variables must specify the current locale environment to be written out. These environment variables will be used if the \fB-a\fR option is not specified. .SH EXIT STATUS -.sp .LP The following exit values are returned: .sp @@ -226,7 +221,6 @@ An error occurred. .RE .SH ATTRIBUTES -.sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -244,12 +238,10 @@ Interface Stability Standard .TE .SH SEE ALSO -.sp .LP \fBlocaledef\fR(1), \fBattributes\fR(5), \fBcharmap\fR(5), \fBenviron\fR(5), \fBlocale\fR(5), \fBstandards\fR(5) .SH NOTES -.sp .LP If \fBLC_CTYPE\fR or keywords in the category \fBLC_CTYPE\fR are specified, only the values in the range \fB0x00\fR-\fB0x7f\fR are written out. diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf index c42953185d..b547cef60f 100644 --- a/usr/src/pkg/manifests/SUNWcs.mf +++ b/usr/src/pkg/manifests/SUNWcs.mf @@ -739,14 +739,12 @@ file path=usr/bin/dumpcs mode=0555 file path=usr/bin/dumpkeys mode=0555 file path=usr/bin/echo mode=0555 file path=usr/bin/ed mode=0555 -file path=usr/bin/egrep mode=0555 file path=usr/bin/eject mode=0555 file path=usr/bin/env mode=0555 file path=usr/bin/expr mode=0555 file path=usr/bin/false mode=0555 file path=usr/bin/fdetach mode=0555 file path=usr/bin/fdformat mode=4555 -file path=usr/bin/fgrep mode=0555 file path=usr/bin/file mode=0555 file path=usr/bin/find mode=0555 file path=usr/bin/fmt mode=0555 @@ -1499,9 +1497,11 @@ hardlink path=usr/bin/digest target=../../usr/lib/isaexec hardlink path=usr/bin/dispgid target=../../usr/bin/ckgid hardlink path=usr/bin/dispuid target=../../usr/bin/ckuid hardlink path=usr/bin/edit target=../has/bin/edit +hardlink path=usr/bin/egrep target=../../usr/bin/grep hardlink path=usr/bin/encrypt target=../../usr/lib/isaexec hardlink path=usr/bin/fc target=../../usr/bin/alias hardlink path=usr/bin/fg target=../../usr/bin/alias +hardlink path=usr/bin/fgrep target=../../usr/bin/grep hardlink path=usr/bin/getopts target=../../usr/bin/alias hardlink path=usr/bin/hash target=../../usr/bin/alias hardlink path=usr/bin/jobs target=../../usr/bin/alias diff --git a/usr/src/pkg/manifests/system-test-utiltest.mf b/usr/src/pkg/manifests/system-test-utiltest.mf index 1bf15858bd..df0e0cfd4e 100644 --- a/usr/src/pkg/manifests/system-test-utiltest.mf +++ b/usr/src/pkg/manifests/system-test-utiltest.mf @@ -216,6 +216,10 @@ file path=opt/util-tests/tests/files/gout6 mode=0444 file path=opt/util-tests/tests/files/gout60 mode=0444 file path=opt/util-tests/tests/files/gout61 mode=0444 file path=opt/util-tests/tests/files/gout62 mode=0444 +file path=opt/util-tests/tests/files/gout63 mode=0444 +file path=opt/util-tests/tests/files/gout64 mode=0444 +file path=opt/util-tests/tests/files/gout65 mode=0444 +file path=opt/util-tests/tests/files/gout66 mode=0444 file path=opt/util-tests/tests/files/gout7 mode=0444 file path=opt/util-tests/tests/files/gout8 mode=0444 file path=opt/util-tests/tests/files/gout9 mode=0444 @@ -227,6 +231,7 @@ file path=opt/util-tests/tests/files/test4 mode=0444 file path=opt/util-tests/tests/files/test5 mode=0444 file path=opt/util-tests/tests/files/test6 mode=0444 file path=opt/util-tests/tests/files/test7 mode=0444 +file path=opt/util-tests/tests/files/testnl mode=0444 file path=opt/util-tests/tests/grep_test mode=0555 file path=opt/util-tests/tests/iconv_test mode=0555 file path=opt/util-tests/tests/libnvpair_json/json_00_blank mode=0555 diff --git a/usr/src/pkg/manifests/system-xopen-xcu4.mf b/usr/src/pkg/manifests/system-xopen-xcu4.mf index 380cffd73d..c9de2bb7fa 100644 --- a/usr/src/pkg/manifests/system-xopen-xcu4.mf +++ b/usr/src/pkg/manifests/system-xopen-xcu4.mf @@ -52,7 +52,6 @@ file path=usr/xpg4/bin/expr mode=0555 file path=usr/xpg4/bin/file mode=0555 file path=usr/xpg4/bin/find mode=0555 file path=usr/xpg4/bin/getconf mode=0555 -file path=usr/xpg4/bin/grep mode=0555 file path=usr/xpg4/bin/id mode=0555 file path=usr/xpg4/bin/link mode=0555 file path=usr/xpg4/bin/ls mode=0555 @@ -67,9 +66,7 @@ file path=usr/xpg4/bin/rm mode=0555 file path=usr/xpg4/bin/sort mode=0555 file path=usr/xpg4/bin/stty mode=0555 file path=usr/xpg4/bin/who mode=0555 -hardlink path=usr/xpg4/bin/egrep target=../../../usr/xpg4/bin/grep hardlink path=usr/xpg4/bin/ex target=../../../usr/xpg4/bin/edit -hardlink path=usr/xpg4/bin/fgrep target=../../../usr/xpg4/bin/grep hardlink path=usr/xpg4/bin/ln target=../../../usr/xpg4/bin/cp hardlink path=usr/xpg4/bin/mv target=../../../usr/xpg4/bin/cp hardlink path=usr/xpg4/bin/vedit target=../../../usr/xpg4/bin/edit @@ -88,9 +85,12 @@ link path=usr/xpg4/bin/bg target=../../bin/alias link path=usr/xpg4/bin/cd target=../../bin/alias link path=usr/xpg4/bin/command target=../../bin/alias link path=usr/xpg4/bin/df target=../../sbin/df +link path=usr/xpg4/bin/egrep target=../../bin/grep link path=usr/xpg4/bin/fc target=../../bin/alias link path=usr/xpg4/bin/fg target=../../bin/alias +link path=usr/xpg4/bin/fgrep target=../../bin/grep link path=usr/xpg4/bin/getopts target=../../bin/alias +link path=usr/xpg4/bin/grep target=../../bin/grep link path=usr/xpg4/bin/hash target=../../bin/alias link path=usr/xpg4/bin/ipcs target=../../bin/ipcs link path=usr/xpg4/bin/jobs target=../../bin/alias diff --git a/usr/src/test/util-tests/tests/grep_xpg4/files/Makefile b/usr/src/test/util-tests/tests/grep_xpg4/files/Makefile index 9edb976649..cec093b8a1 100644 --- a/usr/src/test/util-tests/tests/grep_xpg4/files/Makefile +++ b/usr/src/test/util-tests/tests/grep_xpg4/files/Makefile @@ -90,7 +90,12 @@ PROGS = test0 \ gout59 \ gout60 \ gout61 \ - gout62 + gout62 \ + gout63 \ + gout64 \ + gout65 \ + gout66 \ + testnl CMDS = $(PROGS:%=$(TESTDIR)/%) $(CMDS) := FILEMODE = 0444 diff --git a/usr/src/test/util-tests/tests/grep_xpg4/grep_test.ksh b/usr/src/test/util-tests/tests/grep_xpg4/grep_test.ksh index a544bd789c..0df113d490 100644 --- a/usr/src/test/util-tests/tests/grep_xpg4/grep_test.ksh +++ b/usr/src/test/util-tests/tests/grep_xpg4/grep_test.ksh @@ -15,7 +15,7 @@ # Copyright 2017 Nexenta Systems, Inc. All rights reserved. # -XGREP=${XGREP:=/usr/xpg4/bin/grep} +XGREP=${XGREP:=/usr/bin/grep} FILEDIR=$MY_TESTS/tests/files fail() { diff --git a/usr/src/test/zfs-tests/tests/functional/acl/acl_common.kshlib b/usr/src/test/zfs-tests/tests/functional/acl/acl_common.kshlib index 2d8d02b28e..f6b1e80cbe 100644 --- a/usr/src/test/zfs-tests/tests/functional/acl/acl_common.kshlib +++ b/usr/src/test/zfs-tests/tests/functional/acl/acl_common.kshlib @@ -410,7 +410,7 @@ function get_xattr # fi for xattr in `runat $obj ls | \ - /usr/xpg4/bin/egrep -v -e SUNWattr_ro -e SUNWattr_rw` ; do + /usr/bin/egrep -v -e SUNWattr_ro -e SUNWattr_rw` ; do runat $obj sum $xattr done } diff --git a/usr/src/tools/scripts/elfcmp.sh b/usr/src/tools/scripts/elfcmp.sh index ab27b2064c..c1010419c3 100644 --- a/usr/src/tools/scripts/elfcmp.sh +++ b/usr/src/tools/scripts/elfcmp.sh @@ -24,8 +24,6 @@ # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -#ident "%Z%%M% %I% %E% SMI" -# # elfcmp - compare significant sections in two ELF files # # usage: elfcmp [-v] [-S] [-s section ...] @@ -82,7 +80,7 @@ list_alloc_sections() { } signing_filter() { - /usr/xpg4/bin/grep -v -e \\$SHSTRTAB -e \\.SUNW_signature + /usr/bin/grep -v -e \\$SHSTRTAB -e \\.SUNW_signature } # get section lists for both files into temp files -- 2.11.4.GIT