initool
initool copied to clipboard
[Windows CMD] Cannot write multiple values/only change one value in a file, when not writing to a temporary file first
(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.