Skip to content

fix: use printf instead of echo to fix ANSI color output#4978

Open
Jouini-Mohamed-Chaker wants to merge 1 commit into
anchore:mainfrom
Jouini-Mohamed-Chaker:main
Open

fix: use printf instead of echo to fix ANSI color output#4978
Jouini-Mohamed-Chaker wants to merge 1 commit into
anchore:mainfrom
Jouini-Mohamed-Chaker:main

Conversation

@Jouini-Mohamed-Chaker

Copy link
Copy Markdown

Description

This PR fixes an issue where the install.sh script leaks raw ANSI escape codes (e.g., \033[0;31m) into the terminal output when executed via strict POSIX sh (such as dash).

The echo command does not natively evaluate ANSI color codes in these environments. This update refactors the echo_stderr and log_tag functions to use printf "%b" instead of echo. This ensures cross-shell compatibility and renders the terminal colors correctly regardless of the shell being used.

CLI Output Changes:

Before:
Screenshot 2026-06-12 201015

After:
Screenshot 2026-06-12 201842

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (please discuss with the team first; Syft is 1.0 software and we won't accept breaking changes without going to 2.0)
  • Documentation (updates the documentation)
  • Chore (improve the developer experience, fix a test flake, etc, without changing the visible behavior of Syft)
  • Performance (make Syft run faster or use less memory, without changing visible behavior much)

Checklist

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

Signed-off-by: Jouini Mohamed Chaker <JouiniMohamedChaker@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant