Skip to content

Commit c380a1c

Browse files
committed
Fail early in *nix configuration build script
Adding two exit early safeguards in the *nix configuration build script: 1) Given the initial cd into the build tree fails (the project root), the `buildconf` script exits with non-zero status (failure). 2) Given the grep command does not exist or `configure.ac` AC_INIT [1] expectations are unmet, the buildconf script exits non-zero. Additionally quoting the pathname to cd into and the empty CD_PATH parameter for portability, also for systems that are using a non-portable pathname [2] for the build tree. Rationale: CD-ing into the project root should always prematurely exit w/ FAILURE as a required precondition for its invocation has not been met. This should never go unnoticed as it always requires user intervention. Similar and more specifically to the PHP build on *nix systems, the grep command is required early to obtain the `php_extra_version` from configure.ac. Previously, if the grep command is missing (or failing due to not matching the line with the AC_INIT macro [1]), the internal dev parameter would always be zero (0) which can easily result in the situation that the configure script is not being rebuilt. This is cumbersome as the rebuild of a configure script is more likely required with checked-out dev versions under change rather than an already properly set-up build environment on a dedicated build or release system. Missing the fact that either the grep utility is missing or the expectation of having the AC_INIT macro in configure.ac is unmet should never go unnoticed as it always requires user intervention. [1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Initializing-configure.html [2]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271
1 parent fde053b commit c380a1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

buildconf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ force=0
88
debug=0
99

1010
# Go to project root.
11-
cd $(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
11+
cd "$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" || exit
1212

13-
php_extra_version=$(grep '^AC_INIT(' configure.ac)
13+
php_extra_version=$(grep '^AC_INIT(' configure.ac) || exit
1414
case "$php_extra_version" in
1515
*-dev*)
1616
dev=1

0 commit comments

Comments
 (0)