Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153056173
D25613.id74337.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D25613.id74337.diff
View Options
Index: contrib/netbsd-tests/usr.bin/grep/t_grep.sh
===================================================================
--- contrib/netbsd-tests/usr.bin/grep/t_grep.sh
+++ contrib/netbsd-tests/usr.bin/grep/t_grep.sh
@@ -214,6 +214,56 @@
atf_check -o file:"$(atf_get_srcdir)/d_zgrep.out" zgrep -h line d_input.gz
}
+atf_test_case zgrep_combined_flags
+zgrep_combined_flags_head()
+{
+ atf_set "descr" "Checks for zgrep wrapper problems with combined flags (PR 247126)"
+}
+zgrep_combined_flags_body()
+{
+ echo 'foo bar' > test
+
+ atf_check -o inline:"foo bar\n" zgrep -we foo test
+}
+
+atf_test_case zgrep_eflag
+zgrep_eflag_head()
+{
+ atf_set "descr" "Checks for zgrep wrapper problems with -e PATTERN (PR 247126)"
+}
+zgrep_eflag_body()
+{
+ echo 'foo bar' > test
+
+ atf_check -o inline:"foo bar\n" zgrep -e 'foo bar' test
+}
+
+atf_test_case zgrep_fflag
+zgrep_fflag_head()
+{
+ atf_set "descr" "Checks for zgrep wrapper problems with -f FILE (PR 247126)"
+}
+zgrep_fflag_body()
+{
+ echo foo > pattern
+ echo foobar > test
+
+ # Avoid hang on reading from stdin in the failure case
+ atf_check -o inline:"foobar\n" zgrep -f pattern test </dev/null
+}
+
+atf_test_case zgrep_long_eflag
+zgrep_long_eflag_head()
+{
+ atf_set "descr" "Checks for zgrep wrapper problems --ignore-case reading from stdin (PR 247126)"
+}
+zgrep_long_eflag_body()
+{
+ echo foobar > test
+
+ atf_check -o inline:"foobar\n" zgrep -e foo --ignore-case < test
+}
+
atf_test_case nonexistent
nonexistent_head()
{
@@ -826,6 +876,10 @@
atf_add_test_case file_exp
atf_add_test_case egrep
atf_add_test_case zgrep
+ atf_add_test_case zgrep_combined_flags
+ atf_add_test_case zgrep_eflag
+ atf_add_test_case zgrep_fflag
+ atf_add_test_case zgrep_long_eflag
atf_add_test_case nonexistent
atf_add_test_case context2
# Begin FreeBSD
Index: usr.bin/grep/zgrep.sh
===================================================================
--- usr.bin/grep/zgrep.sh
+++ usr.bin/grep/zgrep.sh
@@ -75,18 +75,31 @@
do
case $1 in
# from GNU grep-2.5.1 -- keep in sync!
- -[ABCDXdefm])
+ --)
+ shift
+ endofopts=1
+ ;;
+ --*)
+ grep_args="${grep_args} $1"
+ shift
+ ;;
+ -*[ABCDXdefm])
if [ $# -lt 2 ]
then
echo "${prg}: missing argument for $1 flag" >&2
exit 1
fi
case $1 in
- -e)
+ -*e)
pattern="$2"
pattern_found=1
shift 2
- break
+ continue
+ ;;
+ -*f)
+ # -f: the pattern is in a file
+ pattern=""
+ pattern_found=1
;;
*)
;;
@@ -94,10 +107,6 @@
grep_args="${grep_args} $1 $2"
shift 2
;;
- --)
- shift
- endofopts=1
- ;;
-)
hyphen=1
shift
@@ -143,15 +152,24 @@
if [ $# -lt 1 ]
then
# ... on stdin
- ${cattool} ${catargs} - | ${grep} ${grep_args} -- "${pattern}" - || ret=$?
+ if [ -n "${pattern}" ]; then
+ ${cattool} ${catargs} - | ${grep} ${grep_args} -- "${pattern}" - || ret=$?
+ else
+ ${cattool} ${catargs} - | ${grep} ${grep_args} -- - || ret=$?
+ fi
else
# ... on all files given on the command line
if [ ${silent} -lt 1 -a $# -gt 1 ]; then
grep_args="-H ${grep_args}"
fi
for file; do
- ${cattool} ${catargs} -- "${file}" |
- ${grep} --label="${file}" ${grep_args} -- "${pattern}" - || ret=$?
+ if [ -n "${pattern}" ]; then
+ ${cattool} ${catargs} -- "${file}" |
+ ${grep} --label="${file}" ${grep_args} -- "${pattern}" - || ret=$?
+ else
+ ${cattool} ${catargs} -- "${file}" |
+ ${grep} --label="${file}" ${grep_args} -- - || ret=$?
+ fi
done
fi
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 19, 9:25 PM (10 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31783433
Default Alt Text
D25613.id74337.diff (3 KB)
Attached To
Mode
D25613: Update zgrep(1) to correctly handle -f FILE and combined flags
Attached
Detach File
Event Timeline
Log In to Comment