diff --git a/ci/release/template/scripts/lib.sh b/ci/release/template/scripts/lib.sh index 8c6d1ec06..9b2b4b7d7 100644 --- a/ci/release/template/scripts/lib.sh +++ b/ci/release/template/scripts/lib.sh @@ -55,20 +55,22 @@ tput() { should_color() { if [ -n "${COLOR-}" ]; then - if [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then - _COLOR=0 + if [ "$COLOR" = 0 -o "$COLOR" = false ]; then + _COLOR= return 1 - elif [ "${COLOR-}" = 1 -o "${COLOR-}" = true ]; then + elif [ "$COLOR" = 1 -o "$COLOR" = true ]; then _COLOR=1 return 0 else printf '$COLOR must be 0, 1, false or true but got %s' "$COLOR" >&2 fi fi + if [ -t 1 ]; then _COLOR=1 return 0 else + _COLOR= return 1 fi } @@ -109,11 +111,12 @@ printfp() {( if [ -z "${FGCOLOR-}" ]; then FGCOLOR="$(get_rand_color "$prefix")" fi - setaf "$FGCOLOR" "[$prefix]" - - if [ $# -gt 0 ]; then - printf ' ' - printf "$@" + if [ $# -eq 0 ]; then + should_color || true + printf '%s' $(COLOR=${_COLOR-} setaf "$FGCOLOR" "$prefix") + else + should_color || true + printf '%s: %s\n' $(COLOR=${_COLOR-} setaf "$FGCOLOR" "$prefix") "$(printf "$@")" fi )} diff --git a/ci/sub b/ci/sub index c5e5d53ca..2eb7e4fa5 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit c5e5d53caa3241629a56b95eaf9780a68546ad61 +Subproject commit 2eb7e4fa5e2457a62140ed3e95c1d75f75cb583c diff --git a/install.sh b/install.sh index a1ac95b45..ff0742739 100755 --- a/install.sh +++ b/install.sh @@ -61,20 +61,22 @@ tput() { should_color() { if [ -n "${COLOR-}" ]; then - if [ "${COLOR-}" = 0 -o "${COLOR-}" = false ]; then - _COLOR=0 + if [ "$COLOR" = 0 -o "$COLOR" = false ]; then + _COLOR= return 1 - elif [ "${COLOR-}" = 1 -o "${COLOR-}" = true ]; then + elif [ "$COLOR" = 1 -o "$COLOR" = true ]; then _COLOR=1 return 0 else printf '$COLOR must be 0, 1, false or true but got %s' "$COLOR" >&2 fi fi + if [ -t 1 ]; then _COLOR=1 return 0 else + _COLOR= return 1 fi } @@ -115,11 +117,12 @@ printfp() {( if [ -z "${FGCOLOR-}" ]; then FGCOLOR="$(get_rand_color "$prefix")" fi - setaf "$FGCOLOR" "[$prefix]" - - if [ $# -gt 0 ]; then - printf ' ' - printf "$@" + if [ $# -eq 0 ]; then + should_color || true + printf '%s' $(COLOR=${_COLOR-} setaf "$FGCOLOR" "$prefix") + else + should_color || true + printf '%s: %s\n' $(COLOR=${_COLOR-} setaf "$FGCOLOR" "$prefix") "$(printf "$@")" fi )}