[developers-reference] 01/01: Don't recommend to use "if [ -x /usr/bin/<cmd> ]; …" in maintainer scripts
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to branch devref-vs-#769845
in repository developers-reference.
commit 5c152e0a5aae7f84c11062643f1065b3b86a34a0
Author: Axel Beckert <abe@deuxchevaux.org>
Date: Thu Dec 7 02:22:43 2017 +0100
Don't recommend to use "if [ -x /usr/bin/<cmd> ]; …" in maintainer scripts
Fixes the equivalent of #769845 (against lintian) in the devref.
With input from the discussion in #807695 (against lintian, too).
---
best-pkging-practices.dbk | 7 +------
common.ent | 13 -------------
2 files changed, 1 insertion(+), 19 deletions(-)
diff --git a/best-pkging-practices.dbk b/best-pkging-practices.dbk
index 27b5eca..51617ec 100644
--- a/best-pkging-practices.dbk
+++ b/best-pkging-practices.dbk
@@ -659,12 +659,7 @@ maintainer script.
If you need to check for the existence of a command, you should use something
like
</para>
-<programlisting>if [ -x /usr/sbin/install-docs ]; then ...</programlisting>
-<para>
-If you don't wish to hard-code the path of a command in your maintainer script,
-the following POSIX-compliant shell function may help:
-</para>
-&example-pathfind;
+<programlisting>if which install-docs > /dev/null; then ...</programlisting>
<para>
You can use this function to search <varname>$PATH</varname> for a command
name, passed as an argument. It returns true (zero) if the command was found,
diff --git a/common.ent b/common.ent
index 1bbed6a..66e0e58 100644
--- a/common.ent
+++ b/common.ent
@@ -256,16 +256,3 @@ pool/non-free/f/firmware-nonfree/
uudecode-file:
perl -ne 'print(unpack "u", $$_);' $(file).uuencoded > $(file)</programlisting>">
-
-<!ENTITY example-pathfind '<programlisting>pathfind() {
- OLDIFS="$IFS"
- IFS=:
- for p in $PATH; do
- if [ -x "$p/$*" ]; then
- IFS="$OLDIFS"
- return 0
- fi
- done
- IFS="$OLDIFS"
- return 1
-}</programlisting>'>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/developers-reference.git
Reply to: