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

Always use the bash as the default shell #824

Merged
merged 2 commits into from
Jan 5, 2022

Conversation

jkremser
Copy link
Member

@jkremser jkremser commented Jan 5, 2022

If the SHELL variable is not specified in the makefile, the env var is used if it exist. If not,
then the /bin/sh alias will be used. This is unpredictable because each OS can have different default
shell implementaion. For instance on Ubuntu it is dash and it behaves differently than bash.

I've tried this in ubuntu container:

foo:
        @$(eval RUNNING_CLUSTERS := $(shell echo 3))
        @$(eval TEST_TAGS := $(shell [ $(RUNNING_CLUSTERS) == 2 ] && echo all || echo rr_multicluster))
        @if [ "$(RUNNING_CLUSTERS)" -lt 2 ] ; then \
        echo "$(RED)Make sure you run the tests against at least two running clusters$(NC)" ;\
        exit 1;\
        fi
        echo "running clusters=$(RUNNING_CLUSTERS)"

make foo

/bin/sh: 1: [: 3: unexpected operator
echo "running clusters=3"
running clusters=3

when I prepended
SHELL=bash in Makefile or changed the /bin/sh symlink from dash to bash, the issue was gone

It's probably a good thing to do to have a predictable environment on different "OSes"

Sorry that I introduced this issue and missed that in the CI output, this should fix https://github.com/k8gb-io/k8gb/runs/4705421875?check_suite_focus=true#step:9:6
Signed-off-by: Jirka Kremser [email protected]

somaritane
somaritane previously approved these changes Jan 5, 2022
Copy link
Contributor

@somaritane somaritane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkremser LGTM!

@kuritka
Copy link
Collaborator

kuritka commented Jan 5, 2022

Hi, I know it's a detail but wouldn be:

# Set the shell to bash always
SHELL := /bin/bash

@jkremser
Copy link
Member Author

jkremser commented Jan 5, 2022

Hi, I know it's a detail but wouldn be:

¯\_(ツ)_/¯ the lazy evaluation of = should not play any role here, right? Because on the right hand side we have a string and nothing dynamic, I was adapting to the style of other assignments in that file... for instance the REPO = absaoss/k8gb 1 line above. But you are probably right that := denotes more something like hey this is not gonna be changed in the future no mater what's on the right side.. no lazy expansion fanciness :D ~ constant

so I can change both lines

If the SHELL variable is not specified in the makefile, the env var is used if it exist. If not,
then the /bin/sh alias will be used. This is unpredictable because each OS can have different default
shell implementaion. For instance on Ubuntu it is dash and it behaves differently than bash.

Signed-off-by: Jirka Kremser <[email protected]>
…separately in other gha)

Signed-off-by: Jirka Kremser <[email protected]>
@jkremser jkremser force-pushed the use-bash-as-default-shell branch from 485a6ec to 406c9d6 Compare January 5, 2022 12:13
@jkremser jkremser requested a review from somaritane January 5, 2022 12:14
@kuritka
Copy link
Collaborator

kuritka commented Jan 5, 2022

it was about /bin/bash x bash rather than assignment. But I say it's just a detail. Anyway A or B, it's good that you added it.
https://github.com/crossplanebook/provider-template/blob/master/Makefile#L1-L2

@jkremser jkremser merged commit 068c638 into k8gb-io:master Jan 5, 2022
@jkremser jkremser deleted the use-bash-as-default-shell branch January 5, 2022 12:29
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.

3 participants