Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[[ not valid in /bin/sh #498

Closed
audetto opened this issue Sep 10, 2023 · 4 comments · Fixed by #500
Closed

[[ not valid in /bin/sh #498

audetto opened this issue Sep 10, 2023 · 4 comments · Fixed by #500

Comments

@audetto
Copy link

audetto commented Sep 10, 2023

I am using Ubuntu 23.04 which links /bin/sh (the shell used by make, see https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html) to dash which does not support [[.

The solution is to force make to use bash with SHELL = /bin/bash

If I send a PR, would you accept it? Better solution?

@sonninnos
Copy link
Collaborator

Sure, let's see it.

@audetto
Copy link
Author

audetto commented Sep 10, 2023

#499

EDIT: or, a bigger change is to drop [[ for a more standard [.

@sonninnos
Copy link
Collaborator

sonninnos commented Sep 10, 2023

Ah, I thought I tried all possibilities, but apparently the thing works fine with just singles:

diff --git a/Makefile b/Makefile
index 8080489ba..61a5d2830 100644
--- a/Makefile
+++ b/Makefile
@@ -461,21 +461,21 @@ endif

 $(OBJDIR)/%.o: %.c
        @mkdir -p $(dir $@)
-       @if [[ $(SILENT) -ne 1 ]]; then\
+       @if [ $(SILENT) -ne 1 ]; then\
                $(if $@, $(shell echo echo CC $<),);\
        fi
        $(CC) $(CFLAGS) -c -o $@ $<

 $(OBJDIR)/%.o: %.cpp
        @mkdir -p $(dir $@)
-       @if [[ $(SILENT) -ne 1 ]]; then\
+       @if [ $(SILENT) -ne 1 ]; then\
                $(if $@, $(shell echo echo CXX $<),);\
        fi
        $(CXX) $(CXXFLAGS) -c -o $@ $<

 $(OBJDIR)/%.o: %.cc
        @mkdir -p $(dir $@)
-       @if [[ $(SILENT) -ne 1 ]]; then\
+       @if [ $(SILENT) -ne 1 ]; then\
                $(if $@, $(shell echo echo CXX $<),);\
        fi
        $(CXX) $(CXXFLAGS) -c -o $@ $<

So should we do this instead?

@audetto
Copy link
Author

audetto commented Sep 10, 2023

Yes, this is simpler.

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 a pull request may close this issue.

2 participants