Thread (27 messages) 27 messages, 4 authors, 2020-11-05

Re: [PATCH iproute2-next v2 03/11] lib: utils: Add print_on_off_bool()

From: Petr Machata <hidden>
Date: 2020-11-03 21:01:45

Leon Romanovsky [off-list ref] writes:
On Tue, Nov 03, 2020 at 12:05:20AM +0100, Petr Machata wrote:
quoted
Leon Romanovsky [off-list ref] writes:
quoted
On Sun, Nov 01, 2020 at 04:55:42PM -0700, David Ahern wrote:
quoted
yes, the rdma utils are using generic function names. The rdma version
should be renamed; perhaps rd_print_on_off. That seems to be once common
prefix. Added Leon.
I made fast experiment and the output for the code proposed here and existed
in the RDMAtool - result the same. So the good thing will be to delete the
function from the RDMA after print_on_off_bool() will be improved.
The RDMAtool uses literal "on" and "off" as values in JSON, not
booleans. Moving over to print_on_off_bool() would be a breaking change,
which is problematic especially in JSON output.
Nothing prohibits us from adding extra parameter to this new
function/json logic/json type that will control JSON behavior. Personally,
I don't think that json and stdout outputs should be different, e.g. 1/0 for
the json and on/off for the stdout.
Emitting on/off in JSON as true booleans (true / false, not 1 / 0) does
make sense. It's programmatically-consumed interface, the values should
be of the right type.

On the other hand, having a FP output use literal "on" and "off" makes
sense as well. It's an obvious reference to the command line, you can
actually cut'n'paste it back to shell and it will do the right thing.

Many places in iproute2 do do this dual output, and ideally all new
instances would behave this way as well. So no toggles, please.
quoted
I think the current function does handle JSON context, what else do
you have in mind?
It handles, but does it twice, first time for is_json_context() and
second time inside print_bool.
Gotcha.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help