From 128e7398f81b481d368ae5af360cd95e4e4652cc Mon Sep 17 00:00:00 2001 From: Richard Burhans Date: Sat, 5 Sep 2026 12:15:45 -0400 Subject: [PATCH] Fix check_shell: $(echo $0) is expanded by make, not the shell check_shell used $(echo $0), which make expands as a variable reference (a variable named "echo $0", undefined -> empty) before the recipe reaches the shell. The test became `[ != "-bash" ]`, a syntax error with no left operand, so `[` exited non-zero and the else branch ran: the target printed "successfully passed" unconditionally, on any shell, and never exited non-zero so `check` could not gate on it. Escaping to $$(echo $$0) is not sufficient: $0 in a recipe is the shell make spawned (/bin/sh), never the string "-bash", which is argv[0] of an interactive login shell. That variant fails unconditionally instead. Test $BASH_VERSION instead, and set SHELL := /bin/bash so recipes actually run under bash rather than dash on Debian/Ubuntu -- which is what the check was asserting all along. The two go together: without the SHELL line a BASH_VERSION test would fail on any system where /bin/sh is dash. under bash: bash detected (5.3.9(1)-release); shell type check successfully passed (exit 0) under dash: ERROR: TOGA2 currently only supports bash ... (exit 1) Recipes were checked for sh-isms; there are none, so running them under bash changes nothing else. --- Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c022d5e..a3ecd50 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +## TOGA2 supports bash only; make's default recipe shell is /bin/sh, which is dash on +## Debian/Ubuntu. Set it explicitly so recipes and check_shell agree. +SHELL := /bin/bash + ARCH=$(shell uname -m) CHECK_DEPS=check_dependencies.py DELIM="==============================" @@ -53,10 +57,11 @@ check_python: python3 ${CHECK_DEPS} python --installation_mode check_shell: - if [ $(echo $0) != "-bash" ]; then \ - echo "ERROR: TOGA2 currently only supports bash as operating shell. Please change you default shell or create a separate environment with bash as default"; \ + @if [ -n "$${BASH_VERSION:-}" ]; then \ + echo "bash detected ($$BASH_VERSION); shell type check successfully passed"; \ else \ - echo "bash has been found to be a default current shell; shell type check successfully passed" ; \ + echo "ERROR: TOGA2 currently only supports bash as operating shell. Please change your default shell or create a separate environment with bash as default" >&2; \ + exit 1; \ fi check_third_party: