Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3221

set_variable_values_ini should be more friendly to whitespaces surrounding =




      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:

      variablename = desired value

      And the "desired value" is what is promised, the file will be
      edited to:

      variablename =desired value

      It should be noted that the allowability of whitespace in INI
      files varies by implementation, as noted in the Wikipedia article:

      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:

          # variablename = default value

      would be changed to:

          variablename= desired value

      With this commit, it will instead be changed to:

          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.




            a10042 Nick Anderson
            a10042 Nick Anderson
            0 Vote for this issue
            1 Start watching this issue