Skip to content

Changed output behavior when using quiet and verbose in version 8.2.0 #931

@AlexanderKlump

Description

@AlexanderKlump

Testing the latest change from version 8.1.9 to 8.2.0 we detected some unexpected change of behavior in the output of our scripts working with zx. I tried to reproduce the observed behavior in the following TS script, which I run with node --loader ts-node/esm --no-warnings=ExperimentalWarning testZx.ts and my node version is v20.10.0.

import { $, LogEntry } from "zx";

await $`echo "$.verbose = ${$.verbose} & $.quiet = ${$.quiet}"`; //from this I infer what is the expected behavior for $.verbose = false and $.quiet = false
$.verbose = true;
await $`echo "$.verbose = ${$.verbose} & $.quiet = ${$.quiet}"`; //from this I infer what is the expected behavior for $.verbose = true and $.quiet = false
await $`echo "$.verbose = ${$.verbose} & $.quiet = ${$.quiet} & .verbose(false)"`.verbose(false); //expected to output nothing
await $`echo "$.verbose = ${$.verbose} & $.quiet = ${$.quiet} & .quiet(true)"`.quiet(true); //expected to output nothing
$.quiet = true;
await $`echo "$.verbose = ${$.verbose} & $.quiet = ${$.quiet}"`; //expected to output nothing
await $`echo "$.verbose = ${$.verbose} & $.quiet = ${$.quiet} & .quiet(false)"`.quiet(false); //expected to output the zx command and its output

$.verbose = false;
await $`echo "$.verbose = ${$.verbose} & $.quiet = ${$.quiet} & .quiet(false)"`.quiet(false); //expected to output nothing

$.verbose = true;

$.log = (entry: LogEntry) => {
    console.log(`entry.kind = ${entry.kind} & entry.verbose = ${entry.verbose}`);
};

$.quiet = false;

await $`echo "Hello World"`; //expected to lead to entry.verbose = true
await $`echo "Hello World"`.quiet(); //expected to lead to entry.verbose = false

With zx version 8.1.9 the output is:

$ echo "$.verbose = true & $.quiet = false"
$.verbose = true & $.quiet = false
$ echo "$.verbose = true & $.quiet = true & .quiet(false)"
$.verbose = true & $.quiet = true & .quiet(false)
entry.kind = cmd & entry.verbose = true
entry.kind = stdout & entry.verbose = true
entry.kind = cmd & entry.verbose = false
entry.kind = stdout & entry.verbose = false

Observations:

  • $.verbose = false and $.quiet = false output nothing
  • $.verbose = true and $.quiet = false output the zx command and its output

With zx version 8.2.0 we get this:

$ echo "$.verbose = true & $.quiet = false"
$.verbose = true & $.quiet = false
$ echo "$.verbose = true & $.quiet = false & .verbose(false)"
$ echo "$.verbose = true & $.quiet = false & .quiet(true)"
$.verbose = true & $.quiet = true & .quiet(false)
entry.kind = cmd & entry.verbose = true
entry.kind = stdout & entry.verbose = true
entry.kind = cmd & entry.verbose = true
entry.kind = stdout & entry.verbose = false

Observations:

  • $.verbose = true & $.quiet = false & .verbose(false) have a different behavior as $.verbose = false and $.quiet = false
  • .quiet(true) does not suppress the zx command to be printed
  • .quiet(false) still suppresses the zx command to be printed
  • the entry.verbose for the cmd kind gets not changed to false anymore if .quiet() is used (this is crucial for us since in our logging function we want to suppress all output if .quiet is used)

For me this looks like an unintended behavior, or do I misperceive something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions