From f89a2552f6011acf77a59ce9d0aabdb25f0e3840 Mon Sep 17 00:00:00 2001 From: Mark Ridgwell <273118822+dnyw4l3n13@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:25:50 +0000 Subject: [PATCH] fix: replace raw echo with output helpers in general/install-latest-dotnet Replace raw echo calls with die/info/success output helpers in general/install-latest-dotnet, consistent with shell-script conventions. Prompt: Work on issue #636 in credfeto/scripts. --- CHANGELOG.md | 1 + general/install-latest-dotnet | 47 +++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de26d01a..14ac0133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release - Replace raw echo with output helpers in general/update-dotnet-tools - Replace raw echo with output helpers in general/stream - Replace raw echo with output helpers in general/ssh-key-mgr +- Replace raw echo with output helpers in general/install-latest-dotnet ### Changed - Replace raw echo with standard output helpers (die/info/success) in github/cancel-workflows - Replace raw echo with standard output helpers (die/info/success) in git/update-repos-personal diff --git a/general/install-latest-dotnet b/general/install-latest-dotnet index ce42aba6..9d63f05d 100755 --- a/general/install-latest-dotnet +++ b/general/install-latest-dotnet @@ -1,11 +1,30 @@ #! /bin/bash die() { - echo - echo "$@" + if [ -t 2 ]; then + printf '\n\033[31m✗\033[0m %s\n' "$*" >&2 + else + printf '\n✗ %s\n' "$*" >&2 + fi exit 1 } +success() { + if [ -t 1 ]; then + printf '\n\033[32m✓\033[0m %s\n' "$*" + else + printf '\n✓ %s\n' "$*" + fi +} + +info() { + if [ -t 1 ]; then + printf '\n\033[32m→\033[0m %s\n' "$*" + else + printf '\n→ %s\n' "$*" + fi +} + # args: @@ -131,22 +150,19 @@ remove_beginning_slash() { } say() { - echo "dotnet-install: $1" + info "dotnet-install: $*" } say_verbose() { if [ "$verbose" = true ]; then - say "$1" + say "$*" fi } say_err() { - say "$1" - exit 1 + die "$*" } -#!/bin/bash - set -e get_latest_dotnet_sdk_version() { @@ -205,11 +221,8 @@ for VERSION in $VERSIONS_TO_INSTALL; do TEMPORARY_FILE="$(mktemp "$temporary_file_template")" - echo "**********************************************************************************************" - echo "* Installing dotnet: $VERSION" - echo "* Current SDK: $SDK_VERSION" - echo "**********************************************************************************************" - echo "" + info "Installing dotnet $VERSION (SDK: $SDK_VERSION)" + DOWNLOAD_URL=$DOWNLOAD_SOURCE/dotnet/Sdk/$SDK_VERSION/dotnet-sdk-$SDK_VERSION-linux-x64.tar.gz curl \ --max-time 120 \ @@ -227,14 +240,12 @@ for VERSION in $VERSIONS_TO_INSTALL; do /usr/share/dotnet/dotnet --list-sdks - echo "" done -echo "Install/update powershell" +info "Install/update powershell" /usr/share/dotnet/dotnet tool update --local PowerShell || dotnet tool install --local PowerShell -echo "Restoring tools" +info "Restoring tools" /usr/share/dotnet/dotnet tool restore - -echo "Done" +success "Done"