View | Details | Raw Unified | Return to bug 247126 | Differences between
and this patch

Collapse All | Expand All

(-)zfgrep (-12 / +25 lines)
Lines 75-92 Link Here
75
do
75
do
76
    case $1 in
76
    case $1 in
77
    # from GNU grep-2.5.1 -- keep in sync!
77
    # from GNU grep-2.5.1 -- keep in sync!
78
	-[ABCDXdefm])
78
	--)
79
	    shift
80
	    endofopts=1
81
	    ;;
82
	--*)
83
	    grep_args="${grep_args} $1"
84
	    shift
85
	    ;;
86
	-*[ABCDXdefm])
79
	    if [ $# -lt 2 ]
87
	    if [ $# -lt 2 ]
80
		then
88
		then
81
		echo "${prg}: missing argument for $1 flag" >&2
89
		echo "${prg}: missing argument for $1 flag" >&2
82
		exit 1
90
		exit 1
83
	    fi
91
	    fi
84
	    case $1 in
92
	    case $1 in
85
		-e)
93
		-*[ef])
86
		    pattern="$2"
94
		    # -e: the pattern is the next argument
95
		    # -f: the pattern(s) is/are in a file
96
		    pattern=""
87
		    pattern_found=1
97
		    pattern_found=1
88
		    shift 2
89
		    break
90
		    ;;
98
		    ;;
91
		*)
99
		*)
92
		    ;;
100
		    ;;
Lines 94-103 Link Here
94
	    grep_args="${grep_args} $1 $2"
102
	    grep_args="${grep_args} $1 $2"
95
	    shift 2
103
	    shift 2
96
	    ;;
104
	    ;;
97
	--)
98
	    shift
99
	    endofopts=1
100
	    ;;
101
	-)
105
	-)
102
	    hyphen=1
106
	    hyphen=1
103
	    shift
107
	    shift
Lines 143-157 Link Here
143
if [ $# -lt 1 ]
147
if [ $# -lt 1 ]
144
then
148
then
145
    # ... on stdin
149
    # ... on stdin
146
    ${cattool} ${catargs} - | ${grep} ${grep_args} -- "${pattern}" - || ret=$?
150
    if [ -n "${pattern}" ]; then
151
	${cattool} ${catargs} - | ${grep} ${grep_args} -- "${pattern}" - || ret=$?
152
    else
153
	${cattool} ${catargs} - | ${grep} ${grep_args} -- - || ret=$?
154
    fi
147
else
155
else
148
    # ... on all files given on the command line
156
    # ... on all files given on the command line
149
    if [ ${silent} -lt 1 -a $# -gt 1 ]; then
157
    if [ ${silent} -lt 1 -a $# -gt 1 ]; then
150
	grep_args="-H ${grep_args}"
158
	grep_args="-H ${grep_args}"
151
    fi
159
    fi
152
    for file; do
160
    for file; do
153
	${cattool} ${catargs} -- "${file}" |
161
	if [ -n "${pattern}" ]; then
154
	    ${grep} --label="${file}" ${grep_args} -- "${pattern}" - || ret=$?
162
	    ${cattool} ${catargs} -- "${file}" |
163
		${grep} --label="${file}" ${grep_args} -- "${pattern}" - || ret=$?
164
	else
165
	    ${cattool} ${catargs} -- "${file}" |
166
		${grep} --label="${file}" ${grep_args} -- - || ret=$?
167
	fi
155
    done
168
    done
156
fi
169
fi
157
170

Return to bug 247126