summaryrefslogtreecommitdiffstats
path: root/ship
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-11-06 18:30:22 +0100
committertv <tv@nomic.retiolum>2013-11-06 18:30:22 +0100
commit20c7db3f85c066fc6c2abbf0ff7af47bdfdaadc9 (patch)
tree002ab52f6acf46a0d767d58d9325e79d88e41906 /ship
parent58718154e9df9609448caf3098932f4df2a796e1 (diff)
ship: talk about Macro Development
Diffstat (limited to 'ship')
-rw-r--r--ship/README.markdown22
1 files changed, 22 insertions, 0 deletions
diff --git a/ship/README.markdown b/ship/README.markdown
index 01a63bd6..9686d099 100644
--- a/ship/README.markdown
+++ b/ship/README.markdown
@@ -30,3 +30,25 @@
Undo `make install` with
make distclean
+
+## Macro Development
+
+ To define a new macro, you have to add a function like
+
+ ## usage: BRE -> FUNCTION_NAME \1 [\2 ...]
+
+ where `BRE` is a basic regular expression, that has to match a whole
+ line. `FUNCTION_NAME` should be the name of a function that outputs
+ a `sed` script. `\1` refers to the line number, where the macro is
+ used and `\2 ...` are the backreferences into `BRE`. E.g.
+
+ ## usage: #@date \([.*]\) -> build_datemacro \1 \2
+ build_datemacro() {
+ printf '%da\\\n%s\n' "$1" "$(date +"$2")"
+ }
+
+ Like in this example, the line number `\1`, which gets mapped to `$1`,
+ is usually used to only change the line, where the macro got called.
+ The second argument gets passed as format specifier to `date`.
+
+ Further examples can be found in `./build`.