Add support for optional argument in -i option for in-place editing
This commit is contained in:
@@ -185,6 +185,18 @@ ParseResult OptionParser::parse(int argc, char **argv) const {
|
|||||||
case 'r':
|
case 'r':
|
||||||
result.options.extendedRegex = true;
|
result.options.extendedRegex = true;
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
// GNU sed accepts -i as an option with an optional argument. When
|
||||||
|
// it appears inside a short-option cluster, any remaining bytes in
|
||||||
|
// that argv word are the backup suffix, e.g. -nri~ == -n -r -i~.
|
||||||
|
// If there are no remaining bytes, it is plain in-place editing and
|
||||||
|
// does not consume the next argv entry.
|
||||||
|
result.options.inPlace = true;
|
||||||
|
if (j + 1 < arg.size()) {
|
||||||
|
result.options.inPlaceSuffix = arg.substr(j + 1);
|
||||||
|
j = arg.size();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
result.options.nullData = true;
|
result.options.nullData = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user