Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

163 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

--- README

Run embedded scripts.

It's basically:
#!/usr/bin/env sh
sed 1,2d "$0" | cc -x c - -o "${0%.*}"; return
If you really think about it.

Bootstrap with ./awake bake.l
then compile further with ./bake,

OR JUST RUN: ./install.sh (try --help)

---

bake [-chln] [-s <n>] <FILENAME> [ARGS...]; version 20260420

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. All (@BAKE - @STOP) statements must precede all (@BAKE - EOL)
statements.

I cannot stress this enough: Bake executes in the directory of the
file specified.

It expands some macros,
  @FILE                 - invoked filename
  @SHORT                - filename without suffix (abc.x.txt \-> abc.x)
  @SHORT:N              - removes N suffixes, so (a.b.c 2 -> a)
  @ARGS                 - other arguments to the program
  @ARGS:N               - Provides the Nth argument, starting from 0
  @ARGS:N+              - All arguments at and after Nth
  @RECURS               - the full path name to the executable
  @RECURS:N             - @RECURS -s N
  @LINE                 - line number at the selected @BAKE

Some additional specialized macros exist:
  @CC                  - cc @ARGS:0 -o @SHORT @FILE @ARGS:1
  @CC:/path/to/cc      - /path/to/cc @ARGS:0 -o @SHORT @FILE @ARGS:1
  @RECUR:N             - @RECURS:N -q @FILE = @RECUR:N

Old way of things that you shouldn't do unless you're me or @agvxov:
  $@ = @FILE
  $* = @SHORT
  $+ = @ARGS
These are also the most supported things in existence, and will work
in basically all versions of 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.

A list of all @BAKEs in a file can be retrieved with
  bake -l file.c
To select one of these, just use
  bake -s <N>

@{filename-to-remove} will remove a specific file when
  bake -x /path/to/file.c
  -> remove at directory of /path/to the file filename-to-remove
with respect to the chosen statement.

See the manpage for more info.

-h --help       | Help message
-n --dry-run	| don't execute or remove anything
-q --quiet      | Only output subprogram output
-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 CC0-1.0.

---

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:
<http://bis64wqhh3louusbd45iyj76kmn4rzw5ysawyan5bkxwyzihj67c5lid.onion/anon/shake>

Bake includes a modified Shake, optionally installation and as the
old bootstrapper. The modified version includes all features of Bake
with the exceptions of multi-line commands and usable expunge.

Changelog

Bake was created on 2023-09-13, and complete as of 2024-03-02.  While
it was completed in 2024-03-02 with a focus on very low, tight memory
usage this was not the final version.

On 2024-09-27, Bake was revised using Flex, which was faster.  I
consider the Flex version finished as of 2025-09-11.  Note that, for a
fully featured version (as in extraneous features), you should
probably seek versions past 2025-12-13.

As of now (2026-04-20), I do not recommend using any prior version as
they were extremely circumstantial (read: the code was more horrifying
than it currently is by an order of magnitude.) Please use the latest
version.

--

2024-03-02

Initial relaase

2024-04-04

Expunge & color.

2024-04 - 2024-08 - 3 Tags of bump -> minor fixes and improvements

2024-09-27

Lex. As adviced by the original creator, I learned and implemented
a Bake with lex. It's fully featured, and has new stuff.

2024-10-24
- Awake

Egor (some dead guy) made an AWK implementation of Bake, it's POSIX.
It doesn't support multi-line, expunge, parses options after filename,
or changing directory to file's directory - it's compatible with Bake
otherwise. It's the new bootstrapper as AWK should be more portable
to the BSDs.

cd /dir/of/file; awake file
See --help

2025-01-04

Introducing some breaking changes.
Removed @FILENAME @NAME, and @FILE_NAME (heyo) leaving only @FILE.
Upgraded ./install.sh to have options.

s/@(FILE_?NAME|NAME)/@FILE/g

This has caused the following damage in retrospect (20260310):

1 (one) file from myself was broken (@NAME), no files were broken for
anyone else.

It broke shakes handling of bake.l, which was untested from 20250104
to 20260310, hence demostrating its lack of use.

Unlike the disrecommendation of $@, $*, & $+, which I've had a problem
with, but I could not remove becuase of usage, the removal is only
harmful with the only upside is Bake is free from weight.

On that:

If I had done it today and time traveled it back,
I'd do what I've done now and include the $ commands paraphrased:
  @$ ; think $var
  @* ; ${input_file%.*}
  @@ ; $@
The actual commands are my misnomer of the above:
  $@ ; @ as in email, funnily enough, it's "backwards"
  $* ; Close enough, but conflicts with Bash. (hence \EVERYTHING)
  $+ ; misremembering of $@, looks like .+ (and the rest)

2025-09-11

-c destroyed from outerspace. -q added. all Bake specific output is
now stderr. use NO_COLOR=1 instead of -c.

2025-12-08

Fixed bug with not literally everything being stderr.  Which was -l
misalignment.

2025-12-13

Bugfix for stderr handling, present only since last. Bug caused by
changes for musl.

Added @CC and @RECUR:N:
@CC = cc @ARGS:0 -o @SHORT @FILE @ARGS:1
@CC:/path/to/compiler = /path/to/compiler @ARGS:0 -o @SHORT @FILE @ARGS:1
@RECUR:N = @RECURS:N -q @FILE

> Why??!
@CC: I wanted something that does what I do in most usages of Bake.
@RECURS:N: This is a nice looking hack benefiting @CC's design.

2026-04-20

Fixed:
When running -s 1 on an file without Bake, there will be a duplicate instance of /file/to/bake.
TERM=dumb not respected for coloration.
@CC should @ARGS:2+. (note that the function for this in prior was geniunely horrifying.)
Doesn't run man on --help despite advertising it.

These were minor issues I had been accumulating with Bake.
This should reduce the applicable general bugs from 0 to -4.

--

@agvxov - the original creator, made a ebuild for Gentoo:
 See <https://bis64wqhh3louusbd45iyj76kmn4rzw5ysawyan5bkxwyzihj67c5lid.onion/~anon/agvxov-overlay>
 (Note: anon still hasn't fixed this build, so don't use it, but he could one day, maybe,
  do the impossible of
  sed -i 's_https://bis64wqhh3louusbd45iyj76kmn4rzw5ysawyan5bkxwyzihj67c5lid.onion/emil/bake.git_https://bis64wqhh3louusbd45iyj76kmn4rzw5ysawyan5bkxwyzihj67c5lid.onion/~emil/bake.git_' bake-9999.ebuild
  ebuild *.ebuild
  )

 packaged under the agvxov overlay as dev-build/bake, see the README
 for including this into your installation.

 This ebuild has since been revised by myself,
 See <https://github.com/8e8m/emillionaire>
 Which is comparable to the above ebuild with versions and a better
 source link of:
 <https://github.com/8e8m/bake>
 Both repos should be in sync, at least in the dev-build/bake-9999 build sense, but mine is sure to work.

debian: Provided in repo, run...
 tar cJvf bake_$VERSION.orig.tar.xz --exclude=debian bake-$VERSION/
 dpkg-buildpackage -us -uc
 dpkg -i ../bake_*.deb

Or download from the releases.

A static build from musl is provided via `-s 2`, however it is
dependent on the non-universal debian specific gcc-musl, please either
change this manually or create a symlink in your system to
`x86_64-pc-linux-musl-gcc` or likewise.

I'm finished with tool for the rest of time.
If I use it and it breaks, I'll fix it. If there's an issue:

Send mail to <mailto:emil@chud.cyou>


About

@BAKE cc -o @SHORT @FILE @ARGS @STOP <- anywhere in file.c; bake file.c -ggdb -fsanitize && ./file # ; etc. Replace @ with @ - blame GitHub.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages