[pacman-dev] [PATCH 3/4] Use @BASH@ instead of hardcoding /bin/bash

Nezmer git at nezmer.info
Mon Oct 11 15:16:48 EDT 2010


 '/bin/bash' is hardcoded in shebangs. bash is not a system shell in
 all platforms and its path is not necessarily '/bin/bash'.

 I used 'which bash' to detect the real path of bash.

Signed-off-by: Nezmer <git at nezmer.info>
---
 contrib/Makefile.am           |    3 +++
 contrib/bacman                |    2 +-
 contrib/pacdiff               |    2 +-
 contrib/pacscripts            |    2 +-
 contrib/pactree               |    2 +-
 contrib/wget-xdelta.sh        |    2 +-
 scripts/Makefile.am           |    3 +++
 scripts/makepkg.sh.in         |    2 +-
 scripts/pacman-optimize.sh.in |    2 +-
 scripts/pkgdelta.sh.in        |    2 +-
 scripts/rankmirrors.sh.in     |    2 +-
 scripts/repo-add.sh.in        |    2 +-
 12 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 337a3f3..4c3b6a6 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -12,8 +12,11 @@ EXTRA_DIST = \
 	zsh_completion \
 	README
 
+BASH := $(shell sh -c 'which bash|| echo /bin/bash')
+
 edit = sed \
 	-e 's|@localstatedir[@]|$(localstatedir)|g' \
+	-e 's|@BASH[@]|$(BASH)|g' \
 	-e 's|@sysconfdir[@]|$(sysconfdir)|g'
 
 # Use sysconfdir
diff --git a/contrib/bacman b/contrib/bacman
index 504ba51..2a93f8b 100755
--- a/contrib/bacman
+++ b/contrib/bacman
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 #
 #   bacman: recreate a package from a running system
 #   This script rebuilds an already installed package using metadata
diff --git a/contrib/pacdiff b/contrib/pacdiff
index 3f26f38..716333a 100755
--- a/contrib/pacdiff
+++ b/contrib/pacdiff
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 #   pacdiff : a simple pacnew/pacorig/pacsave updater
 #
 #   Copyright (c) 2007 Aaron Griffin <aaronmgriffin at gmail.com>
diff --git a/contrib/pacscripts b/contrib/pacscripts
index 3479dc1..123c79d 100755
--- a/contrib/pacscripts
+++ b/contrib/pacscripts
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 #
 #   pacscripts : tries to print out the {pre,post}_{install,remove,upgrade}
 #   scripts of a given package
diff --git a/contrib/pactree b/contrib/pactree
index 8a59a34..29c6af6 100755
--- a/contrib/pactree
+++ b/contrib/pactree
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 # pactree : a simple dependency tree viewer
 #
 # Copyright (C) 2008 Carlo "carlocci" Bersani <carlocci at gmail.com>
diff --git a/contrib/wget-xdelta.sh b/contrib/wget-xdelta.sh
index a77b2b3..caf0171 100755
--- a/contrib/wget-xdelta.sh
+++ b/contrib/wget-xdelta.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 
 if [ -r "@sysconfdir@/makepkg.conf" ]; then
 	source @sysconfdir@/makepkg.conf
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 31e8fb5..5967ab1 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -29,12 +29,15 @@ else
 REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
 endif
 
+BASH := $(shell sh -c 'which bash|| echo /bin/bash')
+
 #### Taken from the autoconf scripts Makefile.am ####
 edit = sed \
 	-e 's|@localedir[@]|$(localedir)|g' \
 	-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
 	-e 's|@localstatedir[@]|$(localstatedir)|g' \
 	-e 's|@prefix[@]|$(prefix)|g' \
+	-e 's|@BASH[@]|$(BASH)|g' \
 	-e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
 	-e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
 	-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 3a7a4d1..baabf26 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!@BASH@ -e
 #
 #   makepkg - make packages compatible for use with pacman
 #   @configure_input@
diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in
index 78b2345..eb6691c 100644
--- a/scripts/pacman-optimize.sh.in
+++ b/scripts/pacman-optimize.sh.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 #
 #   pacman-optimize
 #   @configure_input@
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index 1550fa1..d45678d 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 #
 #   pkgdelta - create delta files for use with pacman and repo-add
 #   @configure_input@
diff --git a/scripts/rankmirrors.sh.in b/scripts/rankmirrors.sh.in
index a0ff6d5..3851b77 100644
--- a/scripts/rankmirrors.sh.in
+++ b/scripts/rankmirrors.sh.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 #
 #   rankmirrors - read a list of mirrors from a file and rank them by speed
 #   @configure_input@
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 8ef940d..4338011 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!@BASH@
 #
 #   repo-add - add a package to a given repo database file
 #   repo-remove - remove a package entry from a given repo database file
-- 
1.7.3.1



More information about the pacman-dev mailing list