diff --git a/src/Options.cpp b/src/Options.cpp index 134b1cd..ba00cbc 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -185,6 +185,18 @@ ParseResult OptionParser::parse(int argc, char **argv) const { case 'r': result.options.extendedRegex = true; 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': result.options.nullData = true; break;