Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ Also, please bear the following coding guidelines in mind:

can be replaced by:

```shell
```bash
bar=${foo//bar/baz}
```

These forms of parameter substitutions can also be used on arrays,
which makes them very powerful (if a little slow).

See ["Pure Bash"](https://github.com/dylanaraps/pure-bash-bible)
for more examples.

- We want our completions to work in `posix` and `nounset` modes.

Unfortunately due to a bash < 5.1 bug, toggling POSIX mode
Expand All @@ -132,7 +135,7 @@ Also, please bear the following coding guidelines in mind:
expansions will be unexpectedly performed, which becomes a vulnerability. In
the latter case, checks by shellcheck and shfmt will not be performed inside
`'...'`. Also, `_comp_compgen_split` is `IFS`-safe.

Avoid using `_comp_compgen -- -G "pattern"` to generate completions. The
result is not filtered by the current word `cur` due to the Bash design of
`compgen`. Also, this cannot be used to generate filenames with a specified
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ list of operating system distributions, package names, and available versions.
Depending on the package, you may still
need to source it from either `/etc/bashrc` or `~/.bashrc` (or any
other file sourcing those). If you have _only_ bash >= 4.2 installed, you can
do this by simply using:
do this by using:

```shell
# Use bash-completion, if available
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
```bash
# Use bash-completion, if available, and avoid double-sourcing
[[ $PS1 &&
-z ${BASH_COMPLETION_VERSINFO:-} &&
-f /usr/share/bash-completion/bash_completion ]] &&
. /usr/share/bash-completion/bash_completion
```

Expand Down Expand Up @@ -70,7 +72,7 @@ standard way is to configure `~/.bash_profile` to source `~/.bashrc` and write
interactive settings in `~/.bashrc`. You can source `~/.bashrc` in
`~/.bash_profile` in the following way:

```shell
```bash
# ~/.bash_profile

if [[ -f ~/.bashrc ]]; then
Expand All @@ -90,7 +92,7 @@ the entry point of `bash-completion` to
`$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh`. We can source it by
adding the following to our startup file `~/.bashrc`:

```shell
```bash
if [[ -s $HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh ]]; then
. "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh"
fi
Expand Down