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

getbtpcli fails with a "bad substitution" error on macOS #6

Closed
qmacro opened this issue Sep 2, 2021 · 1 comment
Closed

getbtpcli fails with a "bad substitution" error on macOS #6

qmacro opened this issue Sep 2, 2021 · 1 comment
Assignees

Comments

@qmacro
Copy link
Contributor

qmacro commented Sep 2, 2021

This issue relates to the content in the 2021-09-01-btp-cli-installation branch of this repo.

Running the getbtpcli script on a standard macOS device results in an error similar to this:

; /bin/bash getbtpcli
/path/to/getbtpcli: line 9: ${PLATFORM,,}-amd64: bad substitution
# ~
;
@qmacro qmacro self-assigned this Sep 2, 2021
@qmacro
Copy link
Contributor Author

qmacro commented Sep 2, 2021

This is because the stock version of the bash shell on macOS, even the latest version of macOS (which, at the time of writing, is Big Sur 11.5.2), is old - at version 3, from 2007. Specifically, the full version information shown is:

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
Copyright (C) 2007 Free Software Foundation, Inc.

Related, and worth mentioning (although it's not directly related to the error described): With the advent of macOS Catalina a couple of years ago, the default login shell on macOS was changed, from bash to zsh.

The error described in this issue is a result of this old version of bash on your machine. You can fix this by installing the latest version which at the time of writing is 5.1.8.

The post Upgrading Bash on macOS takes you through the simple steps.

In fact, to just address the issue here, you only need to carry out the first step, which is to install the latest version of bash with Homebrew:

brew install bash

This will give you a modern bash at /usr/local/bin/bash. You can then simply invoke the getbtpcli script like this:

/usr/local/bin/bash /path/to/getbtpcli

you could even change the hashbang at the top of the script from:

#!/usr/bin/env bash

to

#!/usr/local/bin/bash

These two approaches work for this script, but you have to be explicit because the old version of bash (which is in /bin/bash) is still taking precedence. So to address this, add /usr/local/bin/bash to your $PATH environment variable, before anything else. You'd typically do this in your .bashrc file, like this:

export PATH=/usr/local/bin/bash:$PATH

If you want to go the whole way and upgrade your shell experience to the latest bash version that you've just installed (which will also address the change in default login shell mentioned above), then you can follow the rest of the instructions in that post.

@qmacro qmacro pinned this issue Sep 2, 2021
@qmacro qmacro closed this as completed Sep 2, 2021
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

No branches or pull requests

1 participant