Fix multiple -e pattern options
-f is now working as expected
Protect arguments with space with an eval trick
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 17054 Build 16917: arc lint + arc unit
Event Timeline
usr.bin/grep/zgrep.sh | ||
---|---|---|
99–100 | This needs some sort of quoting to make it come out correctly after eval. Something like this (inspired by ltr in etc/rc.subr) should work: quote() { local part IFS=\'; set -- $1"" unset quote_result for part do quote_result=${quote_result+$quote_result\'\\\'\'}$part done } then surround $quote_result with single-quotes. | |
151 | Suggest passing the parameter expansions literally to eval when possible (all except ${grep_args}) to avoid inappropriate expansion. |
usr.bin/grep/zgrep.sh | ||
---|---|---|
151 | Do you have examples of possible inappropriate expansions? |
usr.bin/grep/zgrep.sh | ||
---|---|---|
151 | A pattern containing a double-quote. The way this is currently written, the double-quote will be special and the pattern will not be interpreted as expected. Using the quote function as for grep_args will make this work; alternatively, use something like `eval ...'${need_pattern:+"${pattern}"}'. The single-quotes ensure a single pass through the parser and expansion for the pattern string. For cattool and catargs you get away with doing it like this because there are no problematic special characters in those. |