fix: Escape ANSI color codes properly in help output

Use printf '%b' instead of cat heredoc to properly interpret
ANSI escape sequences in the show_usage function.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Michel Abboud 2026-01-28 23:22:18 +00:00
parent effdbe0f6f
commit f642f8faa2

View File

@ -927,50 +927,48 @@ cmd_check() {
# ============================================================================== # ==============================================================================
show_usage() { show_usage() {
cat << EOF printf '%b\n' "${BOLD}${SCRIPT_NAME}${RESET} v${SCRIPT_VERSION} - Windows Docker Container Management"
${BOLD}${SCRIPT_NAME}${RESET} v${SCRIPT_VERSION} - Windows Docker Container Management printf '\n'
printf '%b\n' "${BOLD}USAGE${RESET}"
${BOLD}USAGE${RESET} printf ' %s <command> [options]\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} <command> [options] printf '\n'
printf '%b\n' "${BOLD}COMMANDS${RESET}"
${BOLD}COMMANDS${RESET} printf ' %b [version...] Start container(s), interactive if no version\n' "${BOLD}start${RESET}"
${BOLD}start${RESET} [version...] Start container(s), interactive if no version printf ' %b [version...] Stop container(s) with 2-min grace period\n' "${BOLD}stop${RESET}"
${BOLD}stop${RESET} [version...] Stop container(s) with 2-min grace period printf ' %b [version...] Restart container(s)\n' "${BOLD}restart${RESET}"
${BOLD}restart${RESET} [version...] Restart container(s) printf ' %b [version...] Show status of container(s)\n' "${BOLD}status${RESET}"
${BOLD}status${RESET} [version...] Show status of container(s) printf ' %b <version> [-f] View container logs (-f to follow)\n' "${BOLD}logs${RESET}"
${BOLD}logs${RESET} <version> [-f] View container logs (-f to follow) printf ' %b <version> Open bash shell in container\n' "${BOLD}shell${RESET}"
${BOLD}shell${RESET} <version> Open bash shell in container printf ' %b [version...] Show real-time resource usage\n' "${BOLD}stats${RESET}"
${BOLD}stats${RESET} [version...] Show real-time resource usage printf ' %b Build Docker image locally\n' "${BOLD}build${RESET}"
${BOLD}build${RESET} Build Docker image locally printf ' %b [version...] Destroy and recreate container(s)\n' "${BOLD}rebuild${RESET}"
${BOLD}rebuild${RESET} [version...] Destroy and recreate container(s) printf ' %b [category] List versions (desktop/legacy/server/tiny/all)\n' "${BOLD}list${RESET}"
${BOLD}list${RESET} [category] List versions (desktop/legacy/server/tiny/all) printf ' %b <version> Show detailed container info\n' "${BOLD}inspect${RESET}"
${BOLD}inspect${RESET} <version> Show detailed container info printf ' %b [interval] Real-time dashboard (default: 5s refresh)\n' "${BOLD}monitor${RESET}"
${BOLD}monitor${RESET} [interval] Real-time dashboard (default: 5s refresh) printf ' %b Run prerequisites check\n' "${BOLD}check${RESET}"
${BOLD}check${RESET} Run prerequisites check printf ' %b Show this help message\n' "${BOLD}help${RESET}"
${BOLD}help${RESET} Show this help message printf '\n'
printf '%b\n' "${BOLD}CATEGORIES${RESET}"
${BOLD}CATEGORIES${RESET} printf ' desktop Win 11/10/8.1/7 (Pro, Enterprise, LTSC variants)\n'
desktop Win 11/10/8.1/7 (Pro, Enterprise, LTSC variants) printf ' legacy Vista, XP, 2000\n'
legacy Vista, XP, 2000 printf ' server Server 2025/2022/2019/2016/2012/2008/2003\n'
server Server 2025/2022/2019/2016/2012/2008/2003 printf ' tiny Tiny11, Tiny10\n'
tiny Tiny11, Tiny10 printf '\n'
printf '%b\n' "${BOLD}EXAMPLES${RESET}"
${BOLD}EXAMPLES${RESET} printf ' %s start # Interactive menu\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} start # Interactive menu printf ' %s start win11 # Start Windows 11\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} start win11 # Start Windows 11 printf ' %s start win11 win10 # Start multiple\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} start win11 win10 # Start multiple printf ' %s stop win11 # Stop with confirmation\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} stop win11 # Stop with confirmation printf ' %s status # Show all containers\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} status # Show all containers printf ' %s logs win11 -f # Follow logs\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} logs win11 -f # Follow logs printf ' %s list desktop # List desktop versions\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} list desktop # List desktop versions printf ' %s monitor 10 # Dashboard with 10s refresh\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} monitor 10 # Dashboard with 10s refresh printf ' %s rebuild win11 # Recreate container\n' "${SCRIPT_NAME}"
${SCRIPT_NAME} rebuild win11 # Recreate container printf '\n'
printf '%b\n' "${BOLD}PORTS${RESET}"
${BOLD}PORTS${RESET} printf ' Each version has unique ports for Web UI and RDP access.\n'
Each version has unique ports for Web UI and RDP access. printf " Run '%s list' to see port mappings.\n" "${SCRIPT_NAME}"
Run '${SCRIPT_NAME} list' to see port mappings. printf '\n'
EOF
} }
# ============================================================================== # ==============================================================================