From da4e6a80a24bc1002e06b0b4a386254a5d5cb050 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 30 Nov 2018 13:21:50 +1300 Subject: Drop support for Bash <= 3.0 This allows removing a fair bit of boilerplate checking for the availability of `-o bashdefault` for the `complete` builtin, and greatly simplifies the minimum version check. --- bash/bash_completion.d/chgrp.bash | 8 +------- bash/bash_completion.d/ftp.bash | 8 +------- bash/bash_completion.d/git.bash | 9 +-------- bash/bash_completion.d/gpg.bash | 6 +----- bash/bash_completion.d/mail.bash | 6 +----- bash/bash_completion.d/make.bash | 8 +------- bash/bash_completion.d/man.bash | 8 +------- bash/bash_completion.d/mutt.bash | 8 +------- bash/bash_completion.d/mysql.bash | 8 +------- bash/bash_completion.d/openssl.bash | 8 +------- bash/bash_completion.d/sftp.bash | 8 +------- bash/bash_completion.d/ssh-copy-id.bash | 8 +------- bash/bash_completion.d/ssh.bash | 8 +------- bash/bashrc | 9 ++------- 14 files changed, 15 insertions(+), 95 deletions(-) (limited to 'bash') diff --git a/bash/bash_completion.d/chgrp.bash b/bash/bash_completion.d/chgrp.bash index d047f97f..5e93ccee 100644 --- a/bash/bash_completion.d/chgrp.bash +++ b/bash/bash_completion.d/chgrp.bash @@ -11,10 +11,4 @@ _chgrp() { COMPREPLY[${#COMPREPLY[@]}]=$group done < <(compgen -A group -- "${COMP_WORDS[COMP_CWORD]}") } - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _chgrp -o bashdefault -o default chgrp -else - complete -F _chgrp -o default chgrp -fi +complete -F _chgrp -o bashdefault -o default chgrp diff --git a/bash/bash_completion.d/ftp.bash b/bash/bash_completion.d/ftp.bash index 335d711a..d7ee8963 100644 --- a/bash/bash_completion.d/ftp.bash +++ b/bash/bash_completion.d/ftp.bash @@ -30,10 +30,4 @@ _ftp() { COMPREPLY[${#COMPREPLY[@]}]=$machine done } - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _ftp -o bashdefault -o default ftp -else - complete -F _ftp -o default ftp -fi +complete -F _ftp -o bashdefault -o default ftp diff --git a/bash/bash_completion.d/git.bash b/bash/bash_completion.d/git.bash index 2bee169a..2fd1bb98 100644 --- a/bash/bash_completion.d/git.bash +++ b/bash/bash_completion.d/git.bash @@ -198,11 +198,4 @@ _git() { ;; esac } - -# Defaulting to directory/file completion is important in Git's case; -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _git -o bashdefault -o default git -else - complete -F _git -o default git -fi +complete -F _git -o bashdefault -o default git diff --git a/bash/bash_completion.d/gpg.bash b/bash/bash_completion.d/gpg.bash index 6d4cf345..f98cb193 100644 --- a/bash/bash_completion.d/gpg.bash +++ b/bash/bash_completion.d/gpg.bash @@ -16,8 +16,4 @@ _gpg() { } # bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _gpg -o bashdefault -o default gpg -else - complete -F _gpg -o default gpg -fi +complete -F _gpg -o bashdefault -o default gpg diff --git a/bash/bash_completion.d/mail.bash b/bash/bash_completion.d/mail.bash index 4476df12..65c4ae80 100644 --- a/bash/bash_completion.d/mail.bash +++ b/bash/bash_completion.d/mail.bash @@ -3,8 +3,4 @@ declare -F _abook_addresses >/dev/null || source "$HOME"/.bash_completion.d/_abook_addresses.bash # bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _abook_addresses -o bashdefault -o default mail -else - complete -F _abook_addresses -o default mail -fi +complete -F _abook_addresses -o bashdefault -o default mail diff --git a/bash/bash_completion.d/make.bash b/bash/bash_completion.d/make.bash index bb01b36a..c36a039a 100644 --- a/bash/bash_completion.d/make.bash +++ b/bash/bash_completion.d/make.bash @@ -48,10 +48,4 @@ _make() { esac done < "$mf" } - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _make -o bashdefault -o default make -else - complete -F _make -o default make -fi +complete -F _make -o bashdefault -o default make diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash index 3e2cc5be..1efa7c52 100644 --- a/bash/bash_completion.d/man.bash +++ b/bash/bash_completion.d/man.bash @@ -84,10 +84,4 @@ _man() { fi ) } - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _man -o bashdefault -o default man -else - complete -F _man -o default man -fi +complete -F _man -o bashdefault -o default man diff --git a/bash/bash_completion.d/mutt.bash b/bash/bash_completion.d/mutt.bash index d8bcc15d..c7f02ac7 100644 --- a/bash/bash_completion.d/mutt.bash +++ b/bash/bash_completion.d/mutt.bash @@ -1,10 +1,4 @@ # Completion for mutt(1) with abook(1) email addresses declare -F _abook_addresses >/dev/null || source "$HOME"/.bash_completion.d/_abook_addresses.bash - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _abook_addresses -o bashdefault -o default mutt -else - complete -F _abook_addresses -o default mutt -fi +complete -F _abook_addresses -o bashdefault -o default mutt diff --git a/bash/bash_completion.d/mysql.bash b/bash/bash_completion.d/mysql.bash index 5604b3bb..ad153adc 100644 --- a/bash/bash_completion.d/mysql.bash +++ b/bash/bash_completion.d/mysql.bash @@ -50,10 +50,4 @@ _mysql() { fi ) } - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _mysql -o bashdefault -o default mysql -else - complete -F _mysql -o default mysql -fi +complete -F _mysql -o bashdefault -o default mysql diff --git a/bash/bash_completion.d/openssl.bash b/bash/bash_completion.d/openssl.bash index b2bc1b7d..86650770 100644 --- a/bash/bash_completion.d/openssl.bash +++ b/bash/bash_completion.d/openssl.bash @@ -23,10 +23,4 @@ _openssl() { ;; esac } - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _openssl -o bashdefault -o default openssl -else - complete -F _openssl -o default openssl -fi +complete -F _openssl -o bashdefault -o default openssl diff --git a/bash/bash_completion.d/sftp.bash b/bash/bash_completion.d/sftp.bash index 60044e41..ad4d406f 100644 --- a/bash/bash_completion.d/sftp.bash +++ b/bash/bash_completion.d/sftp.bash @@ -1,10 +1,4 @@ # Completion for sftp(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _ssh_config_hosts -o bashdefault -o default sftp -else - complete -F _ssh_config_hosts -o default sftp -fi +complete -F _ssh_config_hosts -o bashdefault -o default sftp diff --git a/bash/bash_completion.d/ssh-copy-id.bash b/bash/bash_completion.d/ssh-copy-id.bash index 5e4fe99b..336df4ea 100644 --- a/bash/bash_completion.d/ssh-copy-id.bash +++ b/bash/bash_completion.d/ssh-copy-id.bash @@ -1,10 +1,4 @@ # Completion for ssh-copy-id(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _ssh_config_hosts -o bashdefault -o default ssh-copy-id -else - complete -F _ssh_config_hosts -o default ssh-copy-id -fi +complete -F _ssh_config_hosts -o bashdefault -o default ssh-copy-id diff --git a/bash/bash_completion.d/ssh.bash b/bash/bash_completion.d/ssh.bash index c8212614..7ec82596 100644 --- a/bash/bash_completion.d/ssh.bash +++ b/bash/bash_completion.d/ssh.bash @@ -1,10 +1,4 @@ # Completion for ssh(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash - -# bashdefault requires Bash >=3.0 -if ((BASH_VERSINFO[0] >= 3)) ; then - complete -F _ssh_config_hosts -o bashdefault -o default ssh -else - complete -F _ssh_config_hosts -o default ssh -fi +complete -F _ssh_config_hosts -o bashdefault -o default ssh diff --git a/bash/bashrc b/bash/bashrc index 8462e5c2..06cbb6b3 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -18,14 +18,9 @@ unalias -a # we should be able to do this even if we're running a truly ancient Bash [ -n "$ENV" ] && . "$ENV" -# Ensure we're using at least version 2.05. Weird arithmetic syntax needed here -# due to leading zeroes and trailing letters in some 2.x version numbers (e.g. -# 2.05a). -# shellcheck disable=SC2128 +# Ensure we're using at least version 3.0. [ -n "$BASH_VERSINFO" ] || return -((BASH_VERSINFO[0] == 2)) && - ((10#${BASH_VERSINFO[1]%%[!0-9]*} < 5)) && - return +((BASH_VERSINFO[0] >= 3)) || return # Clear away command_not_found_handle if a system bashrc file set it up unset -f command_not_found_handle -- cgit v1.2.3