Skip to content

replace echo with printf for portable color output in Makefile#1

Open
Yin-SHT wants to merge 1 commit into
MATCHA-MIT:masterfrom
Yin-SHT:fix-color-bug
Open

replace echo with printf for portable color output in Makefile#1
Yin-SHT wants to merge 1 commit into
MATCHA-MIT:masterfrom
Yin-SHT:fix-color-bug

Conversation

@Yin-SHT

@Yin-SHT Yin-SHT commented Aug 31, 2025

Copy link
Copy Markdown

Description

This PR fixes a portability issue with the Makefile that causes ANSI color codes to be displayed as raw text instead of colored output on various systems.

Problem

The current Makefile uses echo to display colored build messages with ANSI escape sequences. However, echo's handling of escape sequences is inconsistent across different shells and platforms. On my system, the build output shows raw escape codes.

Solution

Replaced all echo commands with printf, which consistently interprets escape sequences across all POSIX-compliant systems:

# Before
@echo "  \033[1;32mCC\033[0m $@"

# After  
@printf "  \033[1;32mCC\033[0m $@\n"

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