Skip to content

Commit b20f9b4

Browse files
authored
BUG: Correct Bash completion path in Makefile
Merge pull request #452 from inkarkat/451-fix-bash-completion
2 parents ca1efb7 + 5b8c3d6 commit b20f9b4

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ jobs:
1818
- run: make
1919
- run: make dist
2020
- run: make test
21-
21+
- run: sudo make install
22+
- run: sudo make uninstall
23+
- run: sudo make clean

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
### Added
1111
- `TODOTXT_DEFAULT_ACTION` now also allows action parameters ([#159], [#407])
1212

13+
### Fixed
14+
- `make install` installed the Bash completion in the wrong directory ([#452])
15+
- `make uninstall` fails ([#451])
16+
1317
## [2.13.0] - 2024-12-25
1418

1519
### Added
@@ -541,3 +545,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
541545
[#359]: https://github.com/todotxt/todo.txt-cli/pull/359
542546
[#386]: https://github.com/todotxt/todo.txt-cli/pull/386
543547
[#407]: https://github.com/todotxt/todo.txt-cli/pull/407
548+
[#451]: https://github.com/todotxt/todo.txt-cli/pull/451
549+
[#452]: https://github.com/todotxt/todo.txt-cli/pull/452

Makefile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,22 @@ ifdef INSTALL_DIR
1919
else
2020
bindir = $(prefix)/bin
2121
endif
22+
DEST_COMMAND = $(DESTDIR)$(bindir)/todo.sh
2223

2324
# The directory to install the config file in.
2425
ifdef CONFIG_DIR
2526
sysconfdir = $(CONFIG_DIR)
2627
else
2728
sysconfdir = $(prefix)/etc
2829
endif
30+
DEST_CONFIG = $(DESTDIR)$(sysconfdir)/todo/config
2931

3032
ifdef BASH_COMPLETION
3133
datarootdir = $(BASH_COMPLETION)
3234
else
33-
datarootdir = $(prefix)/share/bash_completion.d
35+
datarootdir = $(prefix)/share/bash-completion/completions
3436
endif
37+
DEST_COMPLETION = $(DESTDIR)$(datarootdir)/todo.sh
3538

3639
# generate list of targets from this Makefile
3740
# looks for any lowercase target with a double hash mark (##) on the same line
@@ -95,18 +98,18 @@ clean: test-pre-clean VERSION-FILE ## remove dist directory and all release fi
9598

9699
.PHONY: install
97100
install: build installdirs ## local package install
98-
$(INSTALL_PROGRAM) $(DISTNAME)/todo.sh $(DESTDIR)$(bindir)/todo.sh
99-
$(INSTALL_DATA) $(DISTNAME)/todo_completion $(DESTDIR)$(datarootdir)/todo.sh
100-
[ -e $(DESTDIR)$(sysconfdir)/todo/config ] || \
101-
sed "s/^\(export[ \t]*TODO_DIR=\).*/\1~\/.todo/" $(DISTNAME)/todo.cfg > $(DESTDIR)$(sysconfdir)/todo/config
101+
$(INSTALL_PROGRAM) $(DISTNAME)/todo.sh $(DEST_COMMAND)
102+
$(INSTALL_DATA) $(DISTNAME)/todo_completion $(DEST_COMPLETION)
103+
[ -e $(DEST_CONFIG) ] || \
104+
sed "s/^\(export[ \t]*TODO_DIR=\).*/\1~\/.todo/" $(DISTNAME)/todo.cfg > $(DEST_CONFIG)
102105

103106
.PHONY: uninstall
104107
uninstall: ## uninstall package
105-
rm -f $(DESTDIR)$(bindir)/todo.sh
106-
rm -f $(DESTDIR)$(datarootdir)/todo
107-
rm -f $(DESTDIR)$(sysconfdir)/todo/config
108+
rm -f $(DEST_COMMAND)
109+
rm -f $(DEST_COMPLETION)
110+
rm -f $(DEST_CONFIG)
108111

109-
rmdir $(DESTDIR)$(datarootdir)
112+
rmdir $(DESTDIR)$(datarootdir) 2>/dev/null || :
110113
rmdir $(DESTDIR)$(sysconfdir)/todo
111114

112115
# create local installation directories

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ make test
4141

4242
*NOTE:* Makefile defaults to several default paths for installed files. Adjust to your system:
4343

44-
- `INSTALL_DIR`: PATH for executables (default /usr/local/bin)
45-
- `CONFIG_DIR`: PATH for the todo.txt configuration template
46-
- `BASH_COMPLETION`: PATH for autocompletion scripts (default to /etc/bash_completion.d)
44+
- `INSTALL_DIR`: PATH for executables (default `/usr/local/bin`)
45+
- `CONFIG_DIR`: PATH for the `todo/config` configuration template (default `/usr/local/etc`)
46+
- `BASH_COMPLETION`: PATH for autocompletion scripts (default to `/usr/local/share/bash-completion/completions`)
4747

4848
```shell
49-
make install CONFIG_DIR=/etc INSTALL_DIR=/usr/bin BASH_COMPLETION=/usr/share/bash-completion/completions
49+
# Note: Showcasing config overrides for legacy locations; NOT recommended!
50+
make install CONFIG_DIR=/etc INSTALL_DIR=/usr/bin BASH_COMPLETION=/etc/bash_completion.d
5051
```
5152

5253
#### Arch Linux (AUR)

0 commit comments

Comments
 (0)