document and space
This commit is contained in:
parent
4b564dd62b
commit
ead5818956
23
README
23
README
@ -12,7 +12,8 @@ bake [-chln] [-s <n>] <FILENAME> [ARGS...]; version 20240928
|
|||||||
|
|
||||||
Bake is a simple tool meant to execute embedded shell commands within
|
Bake is a simple tool meant to execute embedded shell commands within
|
||||||
any file. It executes with /bin/sh the command after a "@BAKE " to
|
any file. It executes with /bin/sh the command after a "@BAKE " to
|
||||||
the end of the line (a UNIX newline: '\n').
|
the end of the line (a UNIX newline: '\n') or to the first instance of
|
||||||
|
@STOP.
|
||||||
|
|
||||||
It expands some macros,
|
It expands some macros,
|
||||||
@FILENAME @FILE @NAME - filename
|
@FILENAME @FILE @NAME - filename
|
||||||
@ -25,18 +26,24 @@ It expands some macros,
|
|||||||
@LINE - line number at the selected @BAKE
|
@LINE - line number at the selected @BAKE
|
||||||
|
|
||||||
All macros can be exempted by prefixing them with a backslash,
|
All macros can be exempted by prefixing them with a backslash,
|
||||||
which'll be subtracted in the expansion. commands may be
|
which'll be subtracted in the expansion. commands may be spanned over
|
||||||
spanned over several lines with a leading backslash.
|
several lines with a leading backslash.
|
||||||
|
|
||||||
It has five options, this message (-h, --help); prevents the execution
|
-h --help | Help message
|
||||||
of the shell command (-n, --dry-run); list (-l, --list) and select
|
-n --dry-run | don't execute or remove anything
|
||||||
(-s<n>, --select <n>) which respectively lists all @BAKE commands and
|
-c --color | disables color
|
||||||
select & run the Nth command.
|
-l --list | lists available Bake blocks
|
||||||
|
-s --select <n> | selects Nth Bake block
|
||||||
|
-x --expunge | Removes the file specified in the expunge block
|
||||||
|
|
||||||
It roots the shell execution in the directory of the given file.
|
It roots the shell execution in the directory of the given file.
|
||||||
|
|
||||||
Licensed under the public domain.
|
Licensed under the public domain.
|
||||||
|
|
||||||
|
--- Potential Issues
|
||||||
|
|
||||||
|
Whitespace interstring is pruned, which may lead to an issue where you may echo ' ' or require more than one space, please don't do this. If you absolutely need this remove the 'BEGIN PADDING;' statement from the <FOUND>{space} rule. You may also wish to solve the issue with adding a conditional to ' (excluding expunge) and " to wind and not observe the other rules via another group that matches the identity of <OVERLOOK>(.|\n){ ECHO; } & <OVERLOOK>('|"){ BEGIN FOUND; ECHO; }, modify other rules in <FOUND> accordingly.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Shake
|
Shake
|
||||||
@ -58,4 +65,4 @@ Bake was created on 2023/09/13, and complete as of 2024/03/02.
|
|||||||
2024-09-27
|
2024-09-27
|
||||||
|
|
||||||
Lex. As adviced by the original creator, I learned and implemented a
|
Lex. As adviced by the original creator, I learned and implemented a
|
||||||
Bake with lex. Removes facilitated expunge and color, may be rectified.
|
Bake with lex. It's fully featured, and has new stuff.
|
||||||
|
13
bake.1
13
bake.1
@ -8,8 +8,9 @@
|
|||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|
||||||
bake is a simple tool meant to execute embedded shell commands within
|
bake is a simple tool meant to execute embedded shell commands within
|
||||||
any file. It executes with /bin/sh the command after a "\fB@BAKE\fP " to
|
any file. It executes with /bin/sh the command after a "\fB@BAKE\fP "
|
||||||
the end of the line (a UNIX newline: '\fB\\n\fP').
|
to the end of the line (a UNIX newline: '\fB\\n\fP') or to the first
|
||||||
|
instance of @STOP.
|
||||||
|
|
||||||
This format may be embedded within \fBany file\fP.
|
This format may be embedded within \fBany file\fP.
|
||||||
|
|
||||||
@ -19,11 +20,11 @@ Options must always be put before the filename, and short options may be merged
|
|||||||
|
|
||||||
.HP
|
.HP
|
||||||
\-h \-\-help, Help message
|
\-h \-\-help, Help message
|
||||||
\fB\-n \-\-dry\-run\fP, don't execute anything
|
\fB\-n \-\-dry\-run\fP, don't execute or remove anything
|
||||||
\fB\-c \-\-color\fP, disables color
|
\fB\-c \-\-color\fP, disables color
|
||||||
\fB\-l \-\-list\fP, lists available shell commands
|
\fB\-l \-\-list\fP, lists available bake blocks
|
||||||
\fB\-s \-\-select\fP \<n\>, selects Nth shell command
|
\fB\-s \-\-select\fP \<n\>, selects Nth bake block
|
||||||
\fB\-x \-\-expunge\fP, Removes what's specified in the expunge block
|
\fB\-x \-\-expunge\fP, Removes file specified in the expunge block
|
||||||
.PP
|
.PP
|
||||||
Macros
|
Macros
|
||||||
|
|
||||||
|
9
bake.l
9
bake.l
@ -1,6 +1,6 @@
|
|||||||
/* cbake.l @BAKE flex @FILE && cc -Wall -Wextra -std=c99 -D_GNU_SOURCE -o @SHORT lex.yy.c @ARGS -lfl @STOP */
|
/* cbake.l @BAKE flex @FILE && cc -Wall -Wextra -std=c99 -D_GNU_SOURCE -o @SHORT lex.yy.c @ARGS -lfl @STOP */
|
||||||
/* expunge @BAKE flex @FILE && cc -Wall -Wextra -std=c99 -D_GNU_SOURCE -o @{@SHORT} lex.yy.c @ARGS -lfl @STOP */
|
/* expunge @BAKE flex @FILE && cc -Wall -Wextra -std=c99 -D_GNU_SOURCE -o @{@SHORT} lex.yy.c @ARGS -lfl @STOP */
|
||||||
/* expunge @BAKE @STOP */
|
/* Licensed under the public domain. */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -17,6 +17,8 @@
|
|||||||
FILE * g_pipe = NULL, * g_restore, * g_expunge;
|
FILE * g_pipe = NULL, * g_restore, * g_expunge;
|
||||||
int g_ac, g_select = 1, g_color = 1, g_rm = 0;
|
int g_ac, g_select = 1, g_color = 1, g_rm = 0;
|
||||||
char ** g_av, * g_filename, * av0;
|
char ** g_av, * g_filename, * av0;
|
||||||
|
/* show additional padding inter and around command? */
|
||||||
|
int g_skip = 0;
|
||||||
/* for the lexers eyes only */
|
/* for the lexers eyes only */
|
||||||
int line = 1, expunge_depth, first_nl, tmpline;
|
int line = 1, expunge_depth, first_nl, tmpline;
|
||||||
|
|
||||||
@ -64,7 +66,8 @@ MACROS ({CMD}|@STOP|{FILENAME}|@SHORT|@ARGS|@LINE|@RECURS|$@|$*|$+|@\{)
|
|||||||
expunge_depth = 0;
|
expunge_depth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
' { if (g_rm) { STRING("\\'"); } else { ECHO; } }
|
\" { g_skip = 1; ECHO; }
|
||||||
|
' { if (g_rm) { STRING("\\'"); } else { g_skip = 1; ECHO; } }
|
||||||
{CMD}|@STOP { BEGIN INITIAL; yyless(0); if (first_nl) { CHAR('\n'); } if (!g_select) { return 0; } }
|
{CMD}|@STOP { BEGIN INITIAL; yyless(0); if (first_nl) { CHAR('\n'); } if (!g_select) { return 0; } }
|
||||||
\\\n { BEGIN PADDING; ++line; CHAR(' '); }
|
\\\n { BEGIN PADDING; ++line; CHAR(' '); }
|
||||||
{FILENAME}|$@ { STRING(g_filename); }
|
{FILENAME}|$@ { STRING(g_filename); }
|
||||||
@ -76,7 +79,7 @@ MACROS ({CMD}|@STOP|{FILENAME}|@SHORT|@ARGS|@LINE|@RECURS|$@|$*|$+|@\{)
|
|||||||
@LINE { FORMAT("%d", line); }
|
@LINE { FORMAT("%d", line); }
|
||||||
@RECURS { char * prog = realpath(av0, NULL); STRING(prog); free(prog); }
|
@RECURS { char * prog = realpath(av0, NULL); STRING(prog); free(prog); }
|
||||||
\\{MACROS} { STRING(yytext + 1); }
|
\\{MACROS} { STRING(yytext + 1); }
|
||||||
{SPACE} { BEGIN PADDING; CHAR(' '); }
|
{SPACE} { CHAR(' '); if (!g_skip) { BEGIN PADDING; } }
|
||||||
\n { CHAR('\n'); ++line; if (first_nl) { BEGIN STOP; first_nl = 0; tmpline = 0; } }
|
\n { CHAR('\n'); ++line; if (first_nl) { BEGIN STOP; first_nl = 0; tmpline = 0; } }
|
||||||
.|\\' { ECHO; }
|
.|\\' { ECHO; }
|
||||||
}
|
}
|
||||||
|
BIN
test.a.txt
BIN
test.a.txt
Binary file not shown.
Loading…
Reference in New Issue
Block a user