part of shnell – a source to source compiler enhancement tool
© Jens Gustedt, 2017
Evaluate the depending code fragment with protected directives
several times.
This allows to use constructs such as ${N}
also as arguments to subsequent directives.
In it simplest form, something like
will first replace the HERE
in occurences such as
with CMOD
and then call the expansion procedure with input the modified program part, again.
Several identifiers in the line for eval
have the code fragment processed as often as there are such “labels”, last is inner most.
Per default the following directives have shortcuts for amend:
CMOD_AMENDS="${CMOD_AMEND:=
bind
do
env
eval
foreach
let
}"
So the following line, where a variable N
currently has the value 4
,
is then replaced by
The directives that can appear instead of the above can be changed by defining the environment variable CMOD_AMEND
to a list of directives that should have shortcuts. If an element in the list is of the form NEW=OLD
the
directive resolves to
in the depending source snippet.
If only NEW
is given,
resolves to
A particular directive can be switched off by leaving OLD
empty, that is by only giving NEW=
. After that
is ivalid. Thus, by addition of amend=
and/or insert=
to the list all other directives can be disabled for HERE
.
Coding and configuration
The following code is needed to enable the sh-module framework.SRC="$_" . "${0%%/${0##*/}}/import.sh"
Imports
The following sh
-modules are imported: