]> git.xolatile.top Git - emil-bake.git/commitdiff
document and space
authorEmil Williams <emilemilemil@cock.li>
Mon, 30 Sep 2024 15:03:08 +0000 (15:03 +0000)
committerEmil Williams <emilemilemil@cock.li>
Mon, 30 Sep 2024 15:03:08 +0000 (15:03 +0000)
README
bake.1
bake.l
test.a.txt

diff --git a/README b/README
index 55db6a6c549fc6bb4d672994085af52f21cd455f..f02b4bee971235987550554f42b1239dca283826 100644 (file)
--- a/README
+++ b/README
@@ -10,9 +10,10 @@ install by running ./install.sh
 
 bake [-chln] [-s <n>] <FILENAME> [ARGS...]; version 20240928
 
-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
-the end of the line (a UNIX newline: '\n').
+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
+the end of the line (a UNIX newline: '\n') or to the first instance of
+@STOP.
 
 It expands some macros,
   @FILENAME @FILE @NAME - filename
@@ -24,31 +25,37 @@ It expands some macros,
   @RECURS               - the full path name to the executable
   @LINE                 - line number at the selected @BAKE
 
-All macros can be exempted by prefixing them with a backslash,
-which'll be subtracted in the expansion. commands may be
-spanned over several lines with a leading backslash.
+All  macros  can be  exempted  by  prefixing  them with  a  backslash,
+which'll be subtracted in the  expansion. commands may be spanned over
+several lines with a leading backslash.
 
-It has five options, this message (-h, --help); prevents the execution
-of the shell command (-n, --dry-run); list (-l, --list) and select
-(-s<n>, --select <n>) which respectively lists all @BAKE commands and
-select & run the Nth command.
+-h --help      | Help message
+-n --dry-run   | don't execute or remove anything
+-c --color     | disables color
+-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.
 
 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
 
-Bake was inspired by the Bash-based Shake utility (formerly eMake, he
-liked my suggestion for a name).  It is included under authorization
-of its creator.  The original version of Shake may be found at:
+Bake was inspired by the  Bash-based Shake utility (formerly eMake, he
+liked my suggestion  for a name).  It is  included under authorization
+of  its creator.   The  original version  of Shake  may  be found  at:
 <http://bis64wqhh3louusbd45iyj76kmn4rzw5ysawyan5bkxwyzihj67c5lid.onion/anon/shake>
 
-Bake includes a modified Shake, both after installation and as a
+Bake  includes a  modified Shake,  both  after installation  and as  a
 bootstrapper.  The modified version includes all features of Bake with
-the exceptions of multi-line commands.  It is not a general
+the  exceptions  of   multi-line  commands.   It  is   not  a  general
 replacement for Bake.
 
 Changelog
@@ -57,5 +64,5 @@ Bake was created on 2023/09/13, and complete as of 2024/03/02.
 
 2024-09-27
 
-Lex. As adviced by the original creator, I learned and implemented a
-Bake with lex. Removes facilitated expunge and color, may be rectified.
+Lex. As adviced  by the original creator, I learned  and implemented a
+Bake with lex. It's fully featured, and has new stuff.
diff --git a/bake.1 b/bake.1
index 319bdeec312813527c6c2b15e4ed425b0a338e31..b05c4468d6e409bd7b770cb7bf98b1f290bd30bd 100644 (file)
--- a/bake.1
+++ b/bake.1
@@ -8,8 +8,9 @@
 .SH DESCRIPTION
 
 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
-the end of the line (a UNIX newline: '\fB\\n\fP').
+any file.  It executes with /bin/sh the command after a "\fB@BAKE\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.
 
@@ -19,11 +20,11 @@ Options must always be put before the filename, and short options may be merged
 
 .HP
  \-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\-l \-\-list\fP, lists available shell commands
- \fB\-s \-\-select\fP \<n\>, selects Nth shell command
- \fB\-x \-\-expunge\fP, Removes what's specified in the expunge block
+ \fB\-l \-\-list\fP, lists available bake blocks
+ \fB\-s \-\-select\fP \<n\>, selects Nth bake block
+ \fB\-x \-\-expunge\fP, Removes file specified in the expunge block
 .PP
 Macros
 
diff --git a/bake.l b/bake.l
index 5a1069c435acb5db15f0f9e0c3558ebb45350164..43464a80e33e18436e9906132c803c0096dcc19a 100644 (file)
--- a/bake.l
+++ b/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 @STOP */
+/* Licensed under the public domain. */
 
 %{
 #include <ctype.h>
@@ -17,6 +17,8 @@
 FILE  * g_pipe = NULL, * g_restore, * g_expunge;
 int     g_ac, g_select = 1, g_color = 1, g_rm = 0;
 char ** g_av, * g_filename, * av0;
+/* show additional padding inter and around command? */
+int g_skip = 0;
 /* for the lexers eyes only */
 int line = 1, expunge_depth, first_nl, tmpline;
 
@@ -64,7 +66,8 @@ MACROS   ({CMD}|@STOP|{FILENAME}|@SHORT|@ARGS|@LINE|@RECURS|$@|$*|$+|@\{)
    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; } }
  \\\n                 { BEGIN PADDING; ++line; CHAR(' ');                                                    }
  {FILENAME}|$@        { STRING(g_filename);                                                                  }
@@ -76,7 +79,7 @@ MACROS   ({CMD}|@STOP|{FILENAME}|@SHORT|@ARGS|@LINE|@RECURS|$@|$*|$+|@\{)
  @LINE                { FORMAT("%d", line);                                                                  }
  @RECURS              { char * prog = realpath(av0, NULL); STRING(prog); free(prog);                         }
  \\{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; }         }
  .|\\'                { ECHO;                                                                                }
 }
index b09590f312c39349bed5ef621e71f186f18a242d..9bc1154dccb9ad74dbfd3aa0e5020c2c4130d82a 100644 (file)
Binary files a/test.a.txt and b/test.a.txt differ