]> git.proxmox.com Git - systemd.git/blobdiff - tools/find-build-dir.sh
New upstream version 249~rc1
[systemd.git] / tools / find-build-dir.sh
index e449b6e8650aa66e051748b87b6b39160bcc2f33..79a79fcc58e4f866347e21e7c71f099173d83662 100755 (executable)
@@ -1,12 +1,12 @@
 #!/bin/sh
 # SPDX-License-Identifier: LGPL-2.1-or-later
-set -e
+set -eu
 
 # Try to guess the build directory:
 # we look for subdirectories of the parent directory that look like ninja build dirs.
 
-if [ -n "$BUILD_DIR" ]; then
-    echo "$(realpath "$BUILD_DIR")"
+if [ -n "${BUILD_DIR:=}" ]; then
+    realpath "$BUILD_DIR"
     exit 0
 fi
 
@@ -14,20 +14,20 @@ root="$(dirname "$(realpath "$0")")"
 
 found=
 for i in "$root"/../*/build.ninja; do
-    c="$(dirname $i)"
+    c="$(dirname "$i")"
     [ -d "$c" ] || continue
     [ "$(basename "$c")" != mkosi.builddir ] || continue
 
     if [ -n "$found" ]; then
-        echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2
+        echo "Found multiple candidates, specify build directory with \$BUILD_DIR" >&2
         exit 2
     fi
     found="$c"
 done
 
 if [ -z "$found" ]; then
-    echo 'Specify build directory with $BUILD_DIR' >&2
+    echo "Specify build directory with \$BUILD_DIR" >&2
     exit 1
 fi
 
-echo "$(realpath $found)"
+realpath "$found"