Help us improve
Share bugs, ideas, or general feedback.
From bash-development
Explains Bash 5.2 features like variable handling enhancements, nameref improvements, readline 8.2 integration, and array operations with practical examples. Use for Bash 5.2-specific scripting or queries.
npx claudepluginhub jamie-bitflight/claude_skills --plugin bash-developmentHow this skill is triggered — by the user, by Claude, or both
Slash command
/bash-development:bash-52-featuresThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Released in September 2022, Bash 5.2 brought enhancements to variable handling, readline integration, array support, and numerous bug fixes.
Details Bash 5.3 features like in-shell command substitution (${ command; }), REPLY capture (${| command; }), GLOBSORT, and loadable builtins with examples and benchmarks. Useful for modern Bash scripting.
Explains Bash 5.3 features including in-shell ${ command; } substitution, ${| command; } REPLY syntax, enhanced read -E, and source -p. Useful for performant shell scripts.
Writes and reviews defensive Bash scripts for production automation, CI/CD pipelines, system utilities, with strict error handling, portability, testing via Bats, and ShellCheck linting.
Share bugs, ideas, or general feedback.
Released in September 2022, Bash 5.2 brought enhancements to variable handling, readline integration, array support, and numerous bug fixes.
Better error messages and more consistent behavior:
# More informative error messages for readonly variables
readonly CONFIG_PATH="/etc/app/config"
# Attempting to modify generates clearer error
CONFIG_PATH="/tmp/config" # bash: CONFIG_PATH: readonly variable
# Better handling of unset variables with set -u
set -u
# Checking before use is now more reliable
if [[ -n "${OPTIONAL_VAR:-}" ]]; then
echo "Variable is set: ${OPTIONAL_VAR}"
else
echo "Variable is not set"
fi
# Practical example: Configuration validation
validate_config() {
local -a required_vars=("DATABASE_URL" "API_KEY" "LOG_DIR")
local var
for var in "${required_vars[@]}"; do
if [[ -z "${!var:-}" ]]; then
printf 'Error: Required variable %s is not set\n' "${var}" >&2
return 1
fi
done
echo "All required configuration variables are set"
}
export DATABASE_URL="postgres://localhost/db"
export API_KEY="secret123"
export LOG_DIR="/var/log/app"
validate_config
Enhanced reference variable handling.
Significant improvements to command-line editing:
# Better completion behavior in ~/.inputrc
# Skip completions for invisible characters
set skip-completed-text on
# Enhanced history search
# Cycle through history with prefix matching
bind '"\e[A": history-search-backward' # Up arrow
bind '"\e[B": history-search-forward' # Down arrow
# Improved completion coloring
set colored-stats on
set colored-completion-prefix on
# Better handling of long completions
set completion-display-width 0 # Use full terminal width
# Improved array slicing and expansion
array=(10 20 30 40 50 60 70 80 90)
# Slice notation is more reliable
echo "First 3: ${array[@]:0:3}" # 10 20 30
echo "Last 3: ${array[@]: -3}" # 70 80 90
echo "Middle: ${array[@]:3:3}" # 40 50 60
# Practical example: Batch processing
process_batch() {
local -a items=("$@")
local batch_size=3
local i
for ((i = 0; i < ${#items[@]}; i += batch_size)); do
local -a batch=("${items[@]:i:batch_size}")
printf 'Processing batch %d: %s\n' \
"$((i / batch_size + 1))" \
"${batch[*]}"
# Process batch items...
for item in "${batch[@]}"; do
echo " Processing: ${item}"
done
done
}
files=(file1 file2 file3 file4 file5 file6 file7)
process_batch "${files[@]}"
Bash 5.2 includes several security-related fixes:
# Benchmark example showing improved performance
benchmark_arrays() {
local -a array
local i
local start end
start="${EPOCHREALTIME}"
# Large array operations are faster in 5.2
for ((i = 0; i < 10000; i++)); do
array+=("item_${i}")
done
end="${EPOCHREALTIME}"
printf 'Array population time: %.4f seconds\n' \
"$(awk "BEGIN {print ${end} - ${start}}")"
echo "Array size: ${#array[@]}"
}
benchmark_arrays
Generally backward compatible, but note:
# Check for Bash 5.2 features
if [[ "${BASH_VERSINFO[0]}" -eq 5 ]] && [[ "${BASH_VERSINFO[1]}" -ge 2 ]]; then
echo "Bash 5.2+ features available"
# Use enhanced features
elif [[ "${BASH_VERSINFO[0]}" -ge 6 ]]; then
echo "Bash 6.0+ detected"
else
echo "Bash version too old for 5.2 features"
fi
Most scripts work without modification, but consider:
For broader Bash development patterns and best practices, see: