Subject: [bug#44460] Add copyright lines

From: Ludovic Courtès <[email-masked]>
Date: Tue, 10 Nov 2020 23:15:11 +0100

Hi John,

John Soo <[email-masked]> skribis:

>>>From 48945997d9139ddc5e288512de3dda8d5accaf44 Mon Sep 17 00:00:00 2001
> From: John Soo <[email-masked]>
> Date: Wed, 4 Nov 2020 07:51:52 -0800
> Subject: [PATCH] processes: Optionally normalize recutils output.
>
> * guix/scripts/processes.scm: Add "normalize" flag

[...]

> +@table @code
> +@item --normalize
> +Normalize the output records into record sets (@pxref{Record Sets,,,
> +recutils, GNU recutils manual}).  Normalizing into record sets allows
> +joins across record types.
> +
> +@example
> +$ guix processes --normalize | \
> +    recsel \
> +    -j Session \
> +    -t ChildProcess \
> +    -p Session.PID,PID \
> +    -e 'Session.ClientCommand ~ build'
> +Session_PID: 4278
> +PID: 4435
> +
> +Session_PID: 4278
> +PID: 4554
> +
> +Session_PID: 4278
> +PID: 4646
> +@end example
> +@end table

Nice!  Right above the example, I’d suggest adding a sentence like “The
example below lists…” (what does it list actually? :-)).

In the default format, I wonder if we could already change split
‘ChildProcess’ into ‘ChildPID’ and ‘ChildCommand’, as you had initially
proposed on IRC; would that work?

> +(define (lock->record lock port)
> +  (format port "LockHeld: ~a~%" lock))

Maybe ‘lock->recutils’ for consistency and to avoid confusion with
Scheme “records”?

> +(define (format-single-record port)

Maybe ‘daemon-sessions->recutils’?  Should ‘sessions’ be a parameter for
clarity?

> +  "Display denormalized session information to PORT."
> +  (for-each (lambda (session)
> +              (daemon-session->recutils session port)
> +                (newline port))
                  ^
Indentation is off.

> +(define (child-process->normalized-record process port)
> +  "Display PROCESS record on PORT in normalized form"
> +  (format port "PID: ~a" (process-id process))
> +  (newline port)
> +  (format port "Command:~{ ~a~}" (process-command process)))
> +
> +(define (format-normalized port)

Please add a docstring.  Perhaps make ‘sessions’ a parameter?

> +  (define sessions (daemon-sessions))
> +
> +  (format port session-rec-type)

As reported by ‘-Wformat’, passing a non-literal format string is risky;
write this instead:

  (display session-rec-type port)

> +  (newline port)
> +  (newline port)
> +  (for-each
> +   (lambda (session)

Preferable indent ‘for-each’ like so:

  (for-each (lambda (session)

Likewise below.

> +  (display (G_ "
> +  --normalize            display results as normalized record sets"))

Should it be ‘--format=normalized’ (just like we have ‘--format’ in
‘guix describe’, for instance)?

Could you send an updated patch?

Thanks!

Ludo’.