Skip to content

in-place option uses different format #425

Closed

Description

@PranavRJoshi

In GNU sed, the in-place options supports the following format:

$ sed -i script file                              # no backup file produced
$ sed --in-place script file                      # no backup file produced
$ sed -i[SUFFIX] script file                      # backup file of form: file[SUFFIX]
$ sed --in-place=[SUFFIX] script file             # backup file of form: file[SUFFIX]

The current argument parsing function, however, consumes the successive argument for in-place option without checking the form. This is also mentioned in #229.

$ cat temp
quick brown fox

$ ./target/release/sed -i 's/fox/vox/' temp
sed: <script argument 1>:1:1: error: undefined label `emp'

$ sed -i 's/fox/vox/' temp 

$ cat temp
quick brown vox

$ sed -i.bak 's/vox/fox/' temp

$ ls -1
temp
temp.bak

Activity

  1. PranavRJoshi commented on May 13, 2026

    @PranavRJoshi
    ContributorAuthor

    For the format:

    $ sed -i[SUFFIX] file script

    It should be noted that -i and [SUFFIX] must not be space-separated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions