aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-11-30 13:21:50 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-11-30 13:21:50 +1300
commitda4e6a80a24bc1002e06b0b4a386254a5d5cb050 (patch)
tree279f27aae77dc7316cd6d1c85c1f7766f4bb9490
parent0598505cf68b8580ad55c8466470ec7f49d2c241 (diff)
downloaddotfiles-da4e6a80a24bc1002e06b0b4a386254a5d5cb050.tar.gz
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.
-rw-r--r--README.md9
-rw-r--r--bash/bash_completion.d/chgrp.bash8
-rw-r--r--bash/bash_completion.d/ftp.bash8
-rw-r--r--bash/bash_completion.d/git.bash9
-rw-r--r--bash/bash_completion.d/gpg.bash6
-rw-r--r--bash/bash_completion.d/mail.bash6
-rw-r--r--bash/bash_completion.d/make.bash8
-rw-r--r--bash/bash_completion.d/man.bash8
-rw-r--r--bash/bash_completion.d/mutt.bash8
-rw-r--r--bash/bash_completion.d/mysql.bash8
-rw-r--r--bash/bash_completion.d/openssl.bash8
-rw-r--r--bash/bash_completion.d/sftp.bash8
-rw-r--r--bash/bash_completion.d/ssh-copy-id.bash8
-rw-r--r--bash/bash_completion.d/ssh.bash8
-rw-r--r--bash/bashrc9
15 files changed, 19 insertions, 100 deletions
diff --git a/README.md b/README.md
index 8a2f412d..ae9b4319 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ Configuration is included for:
* Bourne-style POSIX shells, sharing a `.profile`, an `ENV` file, and some
helper functions:
- * [GNU Bash](https://www.gnu.org/software/bash/) (2.05a or higher)
+ * [GNU Bash](https://www.gnu.org/software/bash/) (3.0 or higher)
* [Korn shell](http://www.kornshell.com/) (`ksh93`, `pdksh`, `mksh`)
* [Z shell](https://www.zsh.org/)
* [Abook](http://abook.sourceforge.net/) -- curses address book program
@@ -137,8 +137,7 @@ and scripts where I can so that the same files can be loaded for all shells.
On GNU/Linux I use Bash, on BSD I use some variant of Korn Shell, preferably
`ksh93` if it's available.
-As I occasionally have work on very old internal systems, my Bash is written to
-work with [any version 2.05a or
+My Bash is written to work with [any version 3.0 or
newer](http://wiki.bash-hackers.org/scripting/bashchanges). This is why I use
older syntax for certain things such as appending items to arrays:
@@ -150,8 +149,8 @@ actually works for arrays with sparse indices, unlike the above syntax:
array+=("$item")
Where I do use features that are only available in versions of Bash newer than
-2.05a, such as newer `shopt` options or `PROMPT_DIRTRIM`, they are only run
-after testing `BASH_VERSINFO` appropriately.
+3.0, such as newer `shopt` options or `PROMPT_DIRTRIM`, they are only run after
+testing `BASH_VERSINFO` appropriately.
#### Prompt
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