···11{ lib }:
2233let echo_colored_body = start_escape:
44- # Body of a function that behaves like "echo" but
44+ # Body of a function that behaves like "echo" but
55 # has the output colored by the given start_escape
66 # sequence. E.g.
77 #
88 # * echo_x "Building ..."
99 # * echo_x -n "Running "
1010 #
1111- # This is more complicated than apparent at first sight
1111+ # This is more complicated than apparent at first sight
1212 # because:
1313 # * The color markers and the text must be print
1414 # in the same echo statement. Otherise, other
1515- # intermingled text from concurrent builds will
1515+ # intermingled text from concurrent builds will
1616 # be colored as well.
1717 # * We need to preserve the trailing newline of the
1818 # echo if and only if it is present. Bash likes
1919 # to strip those if we capture the output of echo
2020- # in a variable.
2020+ # in a variable.
2121 # * Leading "-" will be interpreted by test as an
2222 # option for itself. Therefore, we prefix it with
2323 # an x in `[[ "x$1" =~ ^x- ]]`.
···2727 echo_args+=" $1"
2828 shift
2929 done
3030-3030+3131 local start_escape="$(printf '${start_escape}')"
3232 local reset="$(printf '\033[0m')"
3333 echo $echo_args $start_escape"$@"$reset
3434 '';
3535 echo_conditional_colored_body = colors: start_escape:
3636- if colors == "always"
3636+ if colors == "always"
3737 then (echo_colored_body start_escape)
3838 else ''echo "$@"'';
3939in {
···5050 noisily = colors: verbose: ''
5151 noisily() {
5252 ${lib.optionalString verbose ''
5353- echo_colored -n "Running "
5353+ echo_colored -n "Running "
5454 echo $@
5555 ''}
5656 $@