dbohdan / dbohdan/initool

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

Open
#19 2 comments 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
Standard ML
Stars
76
Forks
7
PR merge metrics
No merged PRs in 30d

Description

(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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.