Skip to content

Commit

Permalink
Sysconfig: accept leading whitespace before variables
Browse files Browse the repository at this point in the history
Make sure we allow '  var=value' and similar entries in files

Fixes part of https://bugzilla.redhat.com/show_bug.cgi?id=761246
  • Loading branch information
lutter authored and Dominic Cleal committed Mar 13, 2015
1 parent 92f8738 commit 3bc029d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions lenses/sysconfig.aug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions lenses/tests/test_sysconfig.aug
Original file line number Diff line number Diff line change
Expand Up @@ -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: *)

0 comments on commit 3bc029d

Please sign in to comment.