[Libguestfs] [PATCH] convert_linux: translate the first CD-ROM's references in boot conf files

Richard W.M. Jones rjones at redhat.com
Wed Dec 15 10:57:40 UTC 2021


On Wed, Dec 15, 2021 at 11:17:51AM +0100, Laszlo Ersek wrote:
> I *really* dislike the one aspect of the current multi-line messages
> that they are nailed to column #0. It disrupts the code flow for me. For
> example, consider the following snippet from this very file
> [convert/convert_linux.ml]:
> 
>                 g#cp grub_config uefi_grub_conf;
>                 let fix_script = sprintf
> "#!/bin/bash
> efibootmgr -c -L \"CentOS 6\"
> rm -rf %s" uefi_fallback_path in
>                 Firstboot.add_firstboot_script
>                   g inspect.i_root "fix uefi boot" fix_script)
>
> I find it less than ideal.
> 
> I'd really like to indent such strings logically. And that's exactly
> what the backslash is for (I had checked the ocaml documentation): after
> an escaped newline, leading spaces and tabs are dropped. I think that's
> a fantastic feature of OCaml; I used it intentionally.

Right, this is indeed a reason to use the \, as it drops the following
whitespace.

> > You can just match to arbitrary depth in single match statements, so
> > the whole match would become something like:
> > 
> >   let map = map @
> >     match cdroms with
> >     | { Some Source_IDE, Some slot, `RHEL_family v } :: _ when v <= 5 ->
> >            [("hd" ^ drive_name slot, "cdrom")]
> >     | _ -> [] in
> 
> Does this make the code easier to read to you? (Honest question.) To me,
> this does not separate the steps "take first" and "investigate first",
> and so it's harder to read. But if that's only because I don't have
> enough OCaml experience yet, I'm happy to change it. (Because, in
> comparison, you might find the two "match" expressions to be the
> distraction.)

For me it's less code => better, within reason. The above (after
fixing the bugs - see later emails) is more natural.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list