Standardize running code in a single function, include prelude.sh.
[goals.git] / stdlib / prelude.gl
index 70c664c..fdb23e9 100644 (file)
@@ -17,7 +17,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 # This file is included first and automatically in all Goalfiles
-# (unless you use --no-prelude).  It contains standard goals and
+# (unless you use --no-prelude).  It contains standard functions and
 # tactics.
 
 # The only tactic that ‘make’ has.
@@ -27,7 +27,7 @@ tactic *file (filename) = {
 
     # Otherwise rebuild if it is older than any dependency.
     for f in %<; do
-        test %filename -ot "$f" && exit 99 || exit 0
+        test %filename -ot "$f" && exit 99 ||:
     done
 }
 
@@ -36,3 +36,25 @@ tactic *file (filename) = {
 tactic *exists (filename) = {
     test -f %filename || exit 99
 }
+
+#----------------------------------------------------------------------
+# Text functions.
+
+
+
+#----------------------------------------------------------------------
+# File functions.
+
+# Expand a wildcard into a list of filenames.
+function wildcard (wc) = {
+    shopt -s nullglob
+    # Note that the substitution is quoted by goals, so to expand
+    # it we must assign it to a variable and then use it unquoted.
+    wc=%wc
+    echo '['
+    for f in $wc; do
+        quoted_string "$f"
+        echo ','
+    done
+    echo ']'
+}