Skip to content

Commit

Permalink
lenses/fstab.aug: Allow comma after the last option (#838)
Browse files Browse the repository at this point in the history
This PR adds a new lens that allows a comma after the last option:

/dev/mapper/foo-bar / xfs defaults, 0 0

Fixes: #832

Signed-off-by: [email protected]

Signed-off-by: [email protected]
  • Loading branch information
tupyy authored Jul 18, 2024
1 parent 67fabcc commit 5246ef0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lenses/fstab.aug
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Fstab =

let sep_tab = Sep.tab
let sep_spc = Sep.space
let sep_comma_tab = del /,?[ \t]+/ "\t"
let comma = Sep.comma
let eol = Util.eol

Expand All @@ -28,7 +29,7 @@ module Fstab =
[ label "file" . store file ] . sep_tab .
comma_sep_list "vfstype" .
(sep_tab . comma_sep_list "opt" .
(sep_tab . [ label "dump" . store /[0-9]+/ ] .
(sep_comma_tab . [ label "dump" . store /[0-9]+/ ] .
( sep_spc . [ label "passno" . store /[0-9]+/ ])? )? )?
. Util.comment_or_eol ]

Expand Down
11 changes: 11 additions & 0 deletions lenses/tests/test_fstab.aug
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ module Test_fstab =
{ "#comment" = "device at install: /dev/sda3" }
}

(* Bug #832 - Allow comma after the last option *)
test Fstab.lns get "/dev/mapper/foo-bar / xfs defaults, 0 0\n" =
{ "1"
{ "spec" = "/dev/mapper/foo-bar" }
{ "file" = "/" }
{ "vfstype" = "xfs" }
{ "opt" = "defaults" }
{ "dump" = "0" }
{ "passno" = "0" }
}

(* Local Variables: *)
(* mode: caml *)
(* End: *)

0 comments on commit 5246ef0

Please sign in to comment.