Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix building manpages on systems where asciidoc is already installed #169

Merged
merged 1 commit into from
Mar 15, 2025

Conversation

eli-schwartz
Copy link
Contributor

It doesn't really make sense to run one command that isn't installed, to see if another command is installed. Even though I have a2x installed, the build fails with:

make: Entering directory '/var/tmp/portage/dev-vcs/git-absorb-0.7.0/work/git-absorb-0.7.0/Documentation'
make: which: No such file or directory
Makefile:4: *** "No a2x in PATH; install asciidoc.".  Stop.

The "which" utility is not guaranteed to be installed either, and if it is, its behavior is not portable either. This means that when various programs are installed, the which check will report a fatal error because the which tool did not exist and the shell returned a nonzero status when attempting to fork+exec. If it did exist, it might not be an implementation of which that returns nonzero when commands do not exist.

The general scripting suggestion is to use the "command -v" shell builtin; this is required to exist in all POSIX 2008 compliant shells, and is thus guaranteed to work everywhere.

For some in-depth discussions on the topic, see:

Examples of open-source shells likely to be installed as /bin/sh on Linux, which implement the 15-year-old standard: ash, bash, busybox, dash, ksh, mksh and zsh.

Several Linux distros which do currently ship a (decent quality) which utility in their default install are looking to get rid of it:

…talled

It doesn't really make sense to run one command that isn't installed, to
see if another command is installed. Even though I have a2x installed,
the build fails with:

```
make: Entering directory '/var/tmp/portage/dev-vcs/git-absorb-0.7.0/work/git-absorb-0.7.0/Documentation'
make: which: No such file or directory
Makefile:4: *** "No a2x in PATH; install asciidoc.".  Stop.
```

The "which" utility is not guaranteed to be installed either, and if it
is, its behavior is not portable either. This means that when various
programs are installed, the `which` check will report a fatal error
because the which tool did not exist and the shell returned a nonzero
status when attempting to fork+exec. If it did exist, it might not be an
implementation of `which` that returns nonzero when commands do not
exist.

The general scripting suggestion is to use the "command -v" shell
builtin; this is required to exist in all POSIX 2008 compliant shells,
and is thus guaranteed to work everywhere.

For some in-depth discussions on the topic, see:
- https://mywiki.wooledge.org/BashFAQ/081
- https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then/85250#85250

Examples of open-source shells likely to be installed as /bin/sh on
Linux, which implement the 15-year-old standard: ash, bash, busybox,
dash, ksh, mksh and zsh.

Several Linux distros which *do* currently ship a (decent quality)
`which` utility in their default install are looking to get rid of it:

- Gentoo: https://bugs.gentoo.org/646588
- Debian: https://lwn.net/Articles/874049/
gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Mar 13, 2025
doc fail to build if 'which' utility not installed,
replace it with the built-in shell 'command'.

Link: tummychow/git-absorb#169
Closes: https://bugs.gentoo.org/951208
Signed-off-by: Yixun Lan <dlan@gentoo.org>
@tummychow tummychow merged commit c9e90a8 into tummychow:master Mar 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants