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.
*
* 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 \
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
BOLD='\033[1m'
NORMAL='\033[0m'
-MARKNAME="@COMPILECMD"
+MARKNAME="@SHAKE"
MARK="${MARKNAME} "
MARKSTR="${BLUE}${MARKNAME}${NORMAL}"
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
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