Details
-
Type:
Story
-
Status: Done
-
Priority:
(None)
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 3.16.0
-
Component/s: Masterfiles Policy Framework (MPF/COPBL/STDLIB)
-
Labels:None
Description
Originally from: https://github.com/cfengine/masterfiles/pull/1598
Don't make whitespace-only changes to the RHS of INI files
Without this change, if a line is correct except for whitespace,
the file will still be edited and any changes that triggers will
occur, which is undesirable.
For instance, if the file contains:
[sectionname] variablename = desired value
And the "desired value" is what is promised, the file will be
edited to:
[sectionname] variablename =desired value
It should be noted that the allowability of whitespace in INI
files varies by implementation, as noted in the Wikipedia article:
https://en.wikipedia.org/wiki/INI_file#Whitespace
However, these library bundles already allow arbitrary whitespace
between the index (i.e. the LHS) and the equals sign. I submit
that it is inconsistent to allow spaces between the LHS and the
equals sign and to at the same time NOT allow spaces between the
equals sign and the RHS. In other words, it is my belief that
for any INI file where whitespace to the immediate right of the
equals sign is meaningful, whitespace to the immediate left of the
equals sign is meaningful also.
Don't change the whitespace before '=' in INI files when uncommenting
For example, if the value 'desired value' is promised for the key
'variablename' in section 'sectionname', then without this commit, the
following file:
[sectionname] # variablename = default value
would be changed to:
[sectionname] variablename= desired value
With this commit, it will instead be changed to:
[sectionname] variablename = desired value
Which is cosmetically superior.
The change in this commit is not as crucial as the change I made in the
parent commit, but for consistency I believe the field separator regex
passed to the "col" edit_field body should be the same for both calls.