From 3bc029d8e20f8dc6b4464e580a7a91eb98e5f0b9 Mon Sep 17 00:00:00 2001 From: David Lutterkort Date: Mon, 2 Mar 2015 14:55:42 -0800 Subject: [PATCH] Sysconfig: accept leading whitespace before variables Make sure we allow ' var=value' and similar entries in files Fixes part of https://bugzilla.redhat.com/show_bug.cgi?id=761246 --- NEWS | 1 + lenses/sysconfig.aug | 6 ++++-- lenses/tests/test_sysconfig.aug | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 123a8c43d..0d3b6ba74 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ * Dnsmasq: Parse the structure of the 'address' and 'server' options (incompatible change) (Kaarle Ritvanen) * Sudoers: allow '+' in user/groupnames (Andreas Grüninger) + * Sysconfig: handle leading whitespace at beginning of a line, RHBZ#761246 1.3.0 - 2014-11-07 - General changes/additions diff --git a/lenses/sysconfig.aug b/lenses/sysconfig.aug index 8c505b360..5fd6c3800 100644 --- a/lenses/sysconfig.aug +++ b/lenses/sysconfig.aug @@ -46,8 +46,10 @@ module Sysconfig = let word = char* . "\"" . char* in Quote.do_squote (store word+) - let export = Shellvars.export - let kv (value:lens) = [ export? . key key_re . eq . value . comment_or_eol ] + let kv (value:lens) = + let export = Shellvars.export in + let indent = Util.del_opt_ws "" in + [ indent . export? . key key_re . eq . value . comment_or_eol ] let assign = let nothing = del /(""|'')?/ "" . value "" in diff --git a/lenses/tests/test_sysconfig.aug b/lenses/tests/test_sysconfig.aug index fa1601a3b..660844f67 100644 --- a/lenses/tests/test_sysconfig.aug +++ b/lenses/tests/test_sysconfig.aug @@ -148,6 +148,15 @@ unset ONBOOT # We do not want this var test lns get "#MOUNTD_NFS_V3\n#\n" = { "#comment" = "MOUNTD_NFS_V3" } + (* Handle leading whitespace at the beginning of a line correctly *) + test lns get " var=value\n" = { "var" = "value" } + + test lns put " var=value\n" after set "/var" "val2" = " var=val2\n" + + test lns get "\t \tvar=value\n" = { "var" = "value" } + + test lns get " export var=value\n" = { "var" = "value" { "export" } } + (* Local Variables: *) (* mode: caml *) (* End: *)