Skip to content

Commit c4a8fd0

Browse files
authored
Merge pull request #1536 from akinomyoga/sepdir-3
fix: miscellaneous fixes after separation of directories
2 parents b5943fd + 463e589 commit c4a8fd0

File tree

9 files changed

+67
-49
lines changed

9 files changed

+67
-49
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,22 @@ A. [ Disclaimer: Here, how to make the completion code visible to
176176
Install it in one of the directories pointed to by bash-completion's
177177
`pkgconfig` file variables. There are two alternatives:
178178

179-
- The recommended directory is `completionsdir`, which you can get with
179+
- The recommended directory is `<completionsdir>`, which you can get with
180180
`pkg-config --variable=completionsdir bash-completion`. From this
181181
directory, completions are automatically loaded on demand based on invoked
182182
commands' names, so be sure to name your completion file accordingly, and
183183
to include (for example) symbolic links in case the file provides
184-
completions for more than one command. The completion filename for
185-
command `foo` in this directory should be either `foo`, or `foo.bash`.
186-
(Underscore prefixed `_foo` works too, but is reserved for
187-
bash-completion internal use as a deprecation/fallback marker.)
188-
- The other directory which is only present for backwards compatibility,
189-
its usage is no longer recommended, is `compatdir` (get it with
190-
`pkg-config --variable=compatdir bash-completion`). From this
184+
completions for more than one command. The completion filename for command
185+
`foo` in this directory should be `foo.bash`. Unsuffixed `foo` also
186+
works, but it is deprecated in >= 2.18.
187+
- Helper scripts used by completions may be placed in the directory
188+
`<helpersdir>`, which can be retrieved with `pkg-config
189+
--variable=helpersdir bash-completion`. The completion files in
190+
`<completionsdir>` can reference the helper script `<helpersdir>/<helper>`
191+
as `${BASH_SOURCE[0]%/*}/../helpers/<helper>`.
192+
- The other directory, which is only present for backwards compatibility and
193+
is not recommended to use, is `<compatdir>` (get it with
194+
`pkg-config --variable=compatdir bash-completion`). From this
191195
directory, files are loaded eagerly when `bash_completion` is loaded.
192196

193197
For packages using GNU autotools the installation can be handled

bash_completion

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,14 +3506,12 @@ _comp_load()
35063506
shift
35073507
local -a source_args=("$@")
35083508
3509-
local i prefix
3510-
for prefix in "" _; do # Regular from all dirs first, then fallbacks
3511-
for i in "${!dirs[@]}"; do
3512-
dir=${dirs[i]}/completions
3513-
[[ -d $dir ]] || continue
3514-
for compfile in "$prefix$cmdname" "$prefix$cmdname.bash"; do
3515-
_comp_load__visit_file "$dir/$compfile" && return 0
3516-
done
3509+
local i
3510+
for i in "${!dirs[@]}"; do
3511+
dir=${dirs[i]}/completions
3512+
[[ -d $dir ]] || continue
3513+
for compfile in "$cmdname.bash" "$cmdname"; do
3514+
_comp_load__visit_file "$dir/$compfile" && return 0
35173515
done
35183516
done
35193517
_comp_load__visit_file "$_comp__base_directory/completions-core/$cmdname.bash" && return 0

completions-core/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ cross_platform = 2to3.bash \
169169
inject.bash \
170170
inotifywait.bash \
171171
installpkg.bash \
172-
interdiff.bash \
173172
invoke-rc.d.bash \
174173
ip.bash \
175174
ipcalc.bash \

completions-fallback/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ cross_platform = adb.bash \
1717
hexdump.bash \
1818
hwclock.bash \
1919
insmod.bash \
20+
interdiff.bash \
2021
ionice.bash \
2122
jj.bash \
2223
jungle.bash \
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# interdiff(1) completion -*- shell-script -*-
22

3+
# Use of this file is deprecated. Upstream completion is available in
4+
# patchutil >= 0.4.3, use that instead.
5+
36
_comp_cmd_interdiff()
47
{
58
local cur prev words cword was_split comp_args

completions/Makefile.am

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
# We include all the files in the tarball
22

33
bashcompdir = $(datadir)/$(PACKAGE)/completions
4-
bashcomp_DATA =
4+
bashcomp_DATA = README.md
55

6-
symlinks: $(DATA)
7-
.PHONY: symlinks
8-
9-
SETUP_SYMLINKS = $(srcdir)/../setup-symlinks.sh
10-
11-
all-local: ss = $(SETUP_SYMLINKS) .
12-
all-local: symlinks
13-
14-
install-data-hook: ss = $(SETUP_SYMLINKS) $(DESTDIR)$(bashcompdir)
15-
install-data-hook: symlinks
16-
17-
check-local:
18-
REPLY=0; \
19-
for file in $(bashcomp_DATA); do \
20-
$${bashcomp_bash:-$${BASH:-bash}} \
21-
-O extglob -n $(srcdir)/$$file || REPLY=$$?; \
22-
done; \
23-
exit $$REPLY
24-
25-
install-data-local:
26-
$(MKDIR_P) $(DESTDIR)$(datadir)/bash-completion/$(subdir)
27-
28-
uninstall-local:
29-
-rmdir $(DESTDIR)$(datadir)/bash-completion/$(subdir)
6+
EXTRA_DIST = $(bashcomp_DATA)

completions/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# External completions directory - bash-completion
2+
3+
This directory `completions` is the place to put *external* completion files,
4+
i.e., ones not shipped with the bash-completion project. They are loaded by
5+
[bash-completion](https://github.com/scop/bash-completion) on demand.
6+
7+
> [!NOTE]
8+
>
9+
> The core `bash-completion` framework (<= 2.17) has provided also *completion
10+
> files bundled with the bash-completion framework itself* in this directory,
11+
> but we separated those files into `completions-core` and
12+
> `completions-fallback`. However, external completion providers should
13+
> continue to install their completion files in `completions`. The new
14+
> directories `completions-core` and `completions-fallback` are internal
15+
> directories intended to be used by the core bash-completion only.
16+
17+
The programmable completion for the command `<cmd>` is supposed to be provided
18+
in the file `completions/<cmd>.bash`. The implementation examples are found in
19+
`completions-core`, which uses the latest bash-completion API (v3). If you
20+
want to make the completion file to work also with an older version of
21+
`bash-completion`, you need to use the previous API of v2, which is contiuned
22+
to be supported for now. For examples with API v2, please reference the
23+
completion files in `completions` of
24+
[bash-completion-2.11](https://github.com/scop/bash-completion/releases/tag/2.11).

helpers/Makefile.am

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
helpersdir = $(datadir)/$(PACKAGE)/helpers
2-
helpers_DATA =
2+
helpers_DATA = README.md
33

44
EXTRA_DIST = $(helpers_DATA)
5-
6-
install-data-local:
7-
$(MKDIR_P) $(DESTDIR)$(datadir)/bash-completion/$(subdir)
8-
9-
uninstall-local:
10-
-rmdir $(DESTDIR)$(datadir)/bash-completion/$(subdir)

helpers/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# External helpers directory - bash-completion
2+
3+
This directory `helpers` is the place to put *external* helper scripts. i.e.,
4+
ones not shipped with the bash-completion project. They are used by external
5+
completion files in the `completions` directory, written for
6+
[bash-completion](https://github.com/scop/bash-completion).
7+
8+
> [!NOTE]
9+
>
10+
> The core `bash-completion` framework (<= 2.17) has provided also *helper
11+
> scripts included in the bash-completion framework itself* in this directory,
12+
> but we separated those files into `helpers-core`. However, external
13+
> completion providers should continue to install their helper scripts in
14+
> `helpers`. The new directory `helpers-core` is an internal directory
15+
> intended to be used by the core bash-completion only.
16+
17+
The helper script may be referenced by a completion script in `completions`
18+
with `${BASH_COMPLETION[0]%/*}/../helpers/<helper>`.

0 commit comments

Comments
 (0)