[commit: ghc] wip/nfs-locking: Avoid common shell scripting pitfalls (828bc3a)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:15:29 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/828bc3a27a26a02e1bad68ef0c25d7d3a1ce64fd/ghc

>---------------------------------------------------------------

commit 828bc3a27a26a02e1bad68ef0c25d7d3a1ce64fd
Author: David Luposchainsky <dluposchainsky at gmail.com>
Date:   Mon Dec 21 13:46:03 2015 +0100

    Avoid common shell scripting pitfalls
    
    - Get bash from $PATH instead of reading it from /bin/bash (useful for e.g. NixOS)
    - set -euo pipefail: "strict bash mode"
    - Quote all paths to be whitespace compatible
    - GHC uses --make mode automatically


>---------------------------------------------------------------

828bc3a27a26a02e1bad68ef0c25d7d3a1ce64fd
 build.sh | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/build.sh b/build.sh
index d350779..1918cdd 100755
--- a/build.sh
+++ b/build.sh
@@ -1,6 +1,22 @@
-#!/bin/bash -e
+#!/usr/bin/env bash
 
-root=`dirname $0`
-mkdir -p $root/.shake
-ghc --make -Wall $root/src/Main.hs -i$root/src -rtsopts -with-rtsopts=-I0 -outputdir=$root/.shake -o $root/.shake/build
-$root/.shake/build --lint --directory $root/.. $@
+set -euo pipefail
+
+root="$(dirname "$0")"
+
+mkdir -p "$root/.shake"
+
+ghc                           \
+    "$root/src/Main.hs"       \
+    -Wall                     \
+    -i"$root/src"             \
+    -rtsopts                  \
+    -with-rtsopts=-I0         \
+    -outputdir="$root/.shake" \
+    -o "$root/.shake/build"
+
+"$root/.shake/build"       \
+    --lint                 \
+    --directory "$root/.." \
+    --colour               \
+    "$@"



More information about the ghc-commits mailing list