Skip to content

[Windows CMD] Cannot write multiple values/only change one value in a file, when not writing to a temporary file first #19

Description

@e-t-l

(Not a duplicate of #11.)
Do you have to pipe the output to temporary files? Does it not work to overwrite the same file?

e.g.

C:\> initool get filename.ini

[section1]
abc=xyz
[section2]
foo=bar

C:\> initool set filename.ini section1 abc zyx

[section1]
abc=zyx
[section2]
foo=bar

C:\> initool set filename.ini section1 abc zyx > filename.ini
C:\ initool get filename.ini

[section1]
abc=zyx

C:\>

In the above example, I use set to change the value of one key, and then pipe that output back to the original filepath. Although the stdout of set shows all the keys of the original file with just the one key that has changed (this is expected), when it is piped back to the filepath, it overwrites the entire file with just the modified line, deleting all other lines (this is bad).

It's not the end of the world to write the output to a temp file and back, but it's an extra step that seems like it shouldn't be necessary. I'm more concerned by the fact that the stdout from the set command doesn't get written accurately when piped to a file.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions