Skip to content

Commit be0f9da

Browse files
seefoodIra Abramovclaudeakinomyoga
authored
Add bash 4+ version check to pack plugin (#2358)
* Add bash 3.3+ version check to pack plugin The pack plugin uses associative arrays (declare -A) which require bash 4.0+, but has existing checks for bash > 3 on lines 162 and 230. Add early version check to disable and return if bash < 3.3. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Add plugin disable calls to version checks in history-eternal and percol Both plugins already had bash version checks with early returns, but didn't explicitly disable themselves. Now they call _disable-plugin before returning to ensure consistent plugin state. - history-eternal: requires bash 4.3+ for unlimited history - percol: requires bash 4.0+ for bind -x functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Standardize return codes and log messages for version checks Changed both plugins to return 0 instead of 1/nothing and added consistent log messages explaining why the plugin is being disabled: - history-eternal: return 0 with "Disabling history-eternal plugin" message - percol: return 0 with "Disabling percol plugin" message This provides clearer feedback to users and consistent exit codes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * add version checks on install and init * Update bash_it.sh Co-authored-by: Koichi Murase <[email protected]> * By the Book * correct version check --------- Co-authored-by: Ira Abramov <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Koichi Murase <[email protected]>
1 parent ae82116 commit be0f9da

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

bash_it.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/usr/bin/env bash
22
# shellcheck source-path=SCRIPTDIR/lib source-path=SCRIPTDIR/scripts
33
# shellcheck disable=SC2034
4-
#
4+
5+
# Requires bash 3.2+ to install and run
6+
# Skip loading if bash version is too old
7+
if [[ "${BASH_VERSINFO[0]-}" -lt 3 ]] || [[ "${BASH_VERSINFO[0]-}" -eq 3 && "${BASH_VERSINFO[1]}" -lt 2 ]]; then
8+
echo "sorry, but the minimum version of BASH supported by bash_it is 3.2, consider upgrading?" >&2
9+
return 1
10+
fi
11+
512
# Initialize Bash It
613
BASH_IT_LOG_PREFIX="core: main: "
714
: "${BASH_IT:=${BASH_SOURCE%/*}}"

install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/usr/bin/env bash
22
# bash-it installer
33

4+
# Requires bash 3.2+ to install and run
5+
# Skip loading if bash version is too old
6+
if [[ "${BASH_VERSINFO[0]-}" -lt 3 ]] || [[ "${BASH_VERSINFO[0]-}" -eq 3 && "${BASH_VERSINFO[1]}" -lt 2 ]]; then
7+
echo "sorry, but the minimum version of BASH supported by bash_it is 3.2, consider upgrading?" >&2
8+
return 1
9+
fi
10+
411
# Show how to use this installer
512
function _bash-it-install-help() {
613
echo -e "\n$0 : Install bash-it"

plugins/available/history-eternal.plugin.bash

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ url "https://github.com/Bash-it/bash-it"
44

55
if [[ ${BASH_VERSINFO[0]} -lt 4 ]] || [[ ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -lt 3 ]]; then
66
_log_warning "Bash version 4.3 introduced the 'unlimited' history size capability."
7-
return 1
7+
_log_warning "Disabling history-eternal plugin (current version: $BASH_VERSION)"
8+
_disable-plugin history-eternal
9+
return 0
810
fi
911

1012
# Modify history sizes before changing location to avoid unintentionally

plugins/available/pack.plugin.bash

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# shellcheck shell=bash
22
# bash completion for pack -*- shell-script -*-
33

4+
# Requires bash 4+ for associative arrays
5+
# Skip loading if bash version is too old
6+
if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
7+
_disable-plugin pack
8+
return 0
9+
fi
10+
411
cite about-plugin
512
about-plugin 'CNB pack cli aliases'
613
url "https://buildpacks.io/"

plugins/available/percol.plugin.bash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ _command_exists percol || return
1818

1919
if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then
2020
_log_warning "You have to upgrade Bash to Bash v4.x to use the 'percol' plugin."
21-
_log_warning "Your current Bash version is $BASH_VERSION."
22-
return
21+
_log_warning "Disabling percol plugin (current version: $BASH_VERSION)"
22+
_disable-plugin percol
23+
return 0
2324
fi
2425

2526
function _replace_by_history() {

0 commit comments

Comments
 (0)