Skip to content

bashly won't run by default on Mac, due to zsh standard and bash 3.2 #99

@thomasaarholt

Description

@thomasaarholt

The autogenerated files by bashly check for bash version 4 or higher. On MacOS, the default version is version 3.2, because license reasons. This leads to the message bash version 4 or higher is required.

Instead of bash, MacOS defaults to zsh (by default version 5.8 on latest macOS), which afaik supports all the relevant functionality in bash 4+.

I've just done a bit of testing, and there are two solutions:

Solution #1

brew install bash installs the latest bash in the brew directory, then links it to bash, and does not overwrite default shell (zsh is still default). This all that is required for bashly scripts to run, but updating bash can be viewed as invasive by sysadmin.

Solution #2

Specifically, the two following parts of generated bash scripts need editing on Mac:

  • Line 1: #!/usr/bin/env bash -> #!/usr/bin/env zsh
  • Further down, this needs to be commented out or changed to support zsh:
  if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
    printf "bash version 4 or higher is required\n"
    exit 1
  fi

I don't know if there's a way to target "default system shell" in the shebang. That would prevent the problem on Mac, but could lead to issues if one is using e.g. fish shell and has bash 4+ available.

Personally, I'm sticking with solution 1, but I thought I'd share my thoughts here, since there were no results for a search for zsh on the github.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionRequest for help or general question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions