]> git.xolatile.top Git - emil-bake.git/commitdiff
Use @BAKE and @SHAKE, add dry run to @SHAKE
authorEmil <emilwilliams@tuta.io>
Mon, 16 Oct 2023 22:00:21 +0000 (22:00 +0000)
committerEmil <emilwilliams@tuta.io>
Mon, 16 Oct 2023 22:00:21 +0000 (22:00 +0000)
README
bake.c
shake

diff --git a/README b/README
index 631c1c3eeaa5c7eb63b6006cac193943b664d528..2c009eabfdd47685bf3fd8f9a995b4718affe2ca 100644 (file)
--- a/README
+++ b/README
@@ -43,7 +43,8 @@ is included under authorization of it's creator. It is not a replacement
 for Bake, but it is platform independent in regards to its use of Bash.
 
 Shake is limited in comparison to Bake, the first line including @COMPILECMD.
-It supports $@, and $*. It does not support @STOP in any way.
+It supports all Name/Arg Extensions, and all options. It does not support
+@STOP in any way.
 
 Bake is licensed under the GPLv3, See LICENSE.
 
diff --git a/bake.c b/bake.c
index ec03ebecefa15139a12096d3920db853b309b198..08dec9cc2178fc5741a89d419c6bae14e49b081d 100644 (file)
--- a/bake.c
+++ b/bake.c
@@ -3,11 +3,8 @@
  *
  * Licensed under the GNU Public License version 3 only, see LICENSE.
  *
- * For Bake
- * @EXEC cc $@ -o $* -std=gnu89 -O2 -Wall -Wextra -Wpedantic -pipe $CFLAGS @STOP
- *
- * For Shake
- * @COMPILECMD cc $@ -o $* -std=gnu89 -O2 -Wall -Wextra -Wpedantic -pipe $CFLAGS
+ * @BAKE cc $@ -o $* -std=gnu89 -O2 -Wall -Wextra -Wpedantic -pipe $CFLAGS @STOP
+ * @SHAKE cc $@ -o $* -std=gnu89 -O2 -Wall -Wextra -Wpedantic -pipe $CFLAGS
  */
 
 #include <assert.h>
 
 /* Require space after COMPILECMD/EXEC and before STOP (no space required around newline) */
 #define REQUIRE_SPACE
-/* May be be left undefined, comes second */
-/* #define OTHER_START "@COMPILECMD" */
 
-#define START "@EXEC"
+#define START "@BAKE"
 #define  STOP "@STOP"
 #define  HELP                                                                          \
     "target-file [arguments ...]\n"                                                    \
-    "Use the format `@EXEC cmd ...' within the target-file, this will execute the\n"   \
+    "Use the format `@BAKE cmd ...' within the target-file, this will execute the\n"   \
     "rest of line, or if found within the file, until the @STOP marker. You may use\n" \
-    "@COMPILECMD instead of @EXEC.  Whitespace is required after and before both\n"    \
+    "@COMPILECMD instead of @BAKE.  Whitespace is required after and before both\n"    \
     "operators always.\n"
 
 #define DESC                                                \
@@ -148,13 +143,6 @@ find_region(map_t m) {
   char * buf = NULL;
   char * start, * stop;
   start = find(START, m.str, m.str + m.len);
-#ifdef OTHER_START
-  if (!start) {
-    start = find(OTHER_START, m.str, m.str + m.len);
-    start = (char *) /* DON'T QUESTION IT */
-      ((ptrdiff_t) (start - strlen(START) + strlen(OTHER_START)) * (start != 0));
-  }
-#endif /* OTHER_START */
   if (start) {
     start += strlen(START);
 #ifdef REQUIRE_SPACE
diff --git a/shake b/shake
index 25c15362b63f3fe6cdf64d4b2c874d09162e6a09..0fe660e1a78ff10c76c6b659669605eafed4fe1b 100755 (executable)
--- a/shake
+++ b/shake
@@ -7,7 +7,7 @@ GREEN='\033[32m'
 BOLD='\033[1m'
 NORMAL='\033[0m'
 
-MARKNAME="@COMPILECMD"
+MARKNAME="@SHAKE"
 MARK="${MARKNAME} "
 MARKSTR="${BLUE}${MARKNAME}${NORMAL}"
  
@@ -35,6 +35,16 @@ if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
     exit 0
 fi
 
+run=1
+if [[ $1 == "-n" ]] || [[ $1 == "--dry-run" ]]; then
+    if [[ $# -lt 2 ]]; then
+        usage
+        exit 1
+    fi
+    run=0
+    shift 1
+fi
+
 input_file=$1
 shift 1
  
@@ -51,8 +61,10 @@ line=${line//\$+/$@}
 if [[ -n $line ]]; then
     command="${line#*${MARK}}"
     echo "Exec: $command"
-    echo "Output:"
-    eval "$command"
+    if [[ $run -eq 1 ]]; then
+        echo "Output:"
+        eval "$command"
+    fi
 else
     echo -e "${MARKSTR} is not defined." >&2
 fi