aboutsummaryrefslogtreecommitdiff
path: root/doc/wydawca.texi
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-07-24 14:14:47 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-07-24 14:27:11 +0300
commitc047ed856d6d23137ef1df01c1297db36bad3f8c (patch)
tree1999db947cb5e38df8a85d314daa0eef7c7624d0 /doc/wydawca.texi
parent07ea006a31def46ba6ea936dbea366219152d9b6 (diff)
downloadwydawca-c047ed856d6d23137ef1df01c1297db36bad3f8c.tar.gz
wydawca-c047ed856d6d23137ef1df01c1297db36bad3f8c.tar.bz2
Use wordsplit to expand variables in strings.
* NEWS: Raise version number. * configure.ac: Link wydawca.h to include/wydawca Raise version number * doc/wydawca.texi: Document changes. * etc/wydawca.rc: Fix the syntax. * grecs: Upgrace. * include/wydawca/wydawca.h (wy_vlog): New proto. (wy_log, wy_dbg): Format is const char *. (wy_triplet_t): Change typedef. (wy_metadef): Remove struct. (wy_vardef): New struct. (wy_triplet_expand_param) (wy_expand_copy): New protos. * modules/logstat/mod_logstat.c: Update. * modules/mailutils/Makefile.am (AM_CPPFLAGS): Modify, * modules/mailutils/mod_mailutils.c: Update. * src/Makefile.am (wydawca_SOURCES): Remove meta.c * src/dictionary.c: Fix comment. * src/directive.c (directive_get_value): Triplet pointer is const. * src/meta.c: Remove. * src/timer.c: (timer_fill_meta) (timer_free_meta): Remove. * src/triplet.c: Use wordsplit for expansions. * src/wydawca.c (wy_vlog): New function. (wy_stat_expansion): New function. * src/wydawca.h: Remove metadef protos. * tests/etc/notify.rcin: Update variable reference syntax.
Diffstat (limited to 'doc/wydawca.texi')
-rw-r--r--doc/wydawca.texi156
1 files changed, 84 insertions, 72 deletions
diff --git a/doc/wydawca.texi b/doc/wydawca.texi
index 2763b6d..8950987 100644
--- a/doc/wydawca.texi
+++ b/doc/wydawca.texi
@@ -730,48 +730,64 @@ example above:
-@anchor{meta-interpretation}
-@cindex meta-interpretation
-@cindex meta-variables
-Depending on the context, the contents of a quoted string may be
-subject to @dfn{meta-variable interpretation}. During this process,
-any sequence
+@anchor{variable expansion}
+@cindex variable expansion
+@cindex variables
+Depending on the context, the quoted string may be subject to
+@dfn{variable expansion}.
-@smallexample
-$@{@var{var}@}
-@end smallexample
+During variable expansion, references to variables
+in the string are replaced with their actual values. A variable
+reference has two basic forms:
-@noindent
-where @var{var} is the name of a defined meta-variable, is replaced with
-the value of the variable. This sequence is called @dfn{meta-
-reference}. For example, if the meta-variable @samp{user} has the
-value @samp{smith}, then the string
-
-@smallexample
-"where user = '$@{user@}'"
-@end smallexample
+@example
+ $@var{v}
+ $@{@var{v}@}
+@end example
@noindent
-becomes
+where @var{v} is the variable name. The notation in curly braces
+serves several purposes. First, it should be used if the variable
+reference is immediately followed by an alphanumeric symbol, which
+will otherwise be considered part of it (as in @samp{$@{home@}dir}).
+Secondly, this form allows for specifying the action to take if the
+variable is undefined or expands to an empty value.
-@smallexample
-"where user = 'smith'"
-@end smallexample
-
-If the name of the variable consists of a single character, the curly
-braces around it may be omitted. Thus, @code{$@{u@}} and @code{$u} are
-equivalent.
+The following special forms are recognized:
-If @var{var} is not defined, the meta-reference is left unchanged.
+@table @asis
+@item $@{@var{variable}:-@var{word}@}
+@dfn{Use Default Values}. If @var{variable} is unset or null, the expansion
+of @var{word} is substituted. Otherwise, the value of @var{variable} is
+substituted.
+
+@item $@{@var{variable}:=@var{word}@}
+@dfn{Assign Default Values}. If @var{variable} is unset or null, the
+expansion of @var{word} is assigned to variable. The value of
+@var{variable} is then substituted.
+
+The assigned value remains in effet during expansion of the current string.
+
+@item $@{@var{variable}:?@var{word}@}
+@dfn{Display Error if Null or Unset}. If @var{variable} is null or unset,
+the expansion of @var{word} (or a message to that effect if @var{word} is
+not present) is output to the current logging channel. Otherwise, the
+value of @var{variable} is substituted.
+
+@item $@{@var{variable}:+@var{word}@}
+@dfn{Use Alternate Value}. If @var{variable} is null or unset, nothing is
+substituted, otherwise the expansion of @var{word} is substituted.
+@end table
-The special sequence @samp{$-} causes removal of it and any character
-following it. Most often it is used as a next-to-last character
-on a line, right before the newline. In this position it causes the
-removal of the trailing newline, similar to @samp{dnl} in @command{m4}.
-@xref{listings, Triplet Listings}, for a detailed description and
-examples of @samp{$-} use.
+These constructs test for a variable that is unset or null. Omitting
+the colon results in a test only for a variable that is unset.
-To insert a literal @samp{$} character in a string that is subject to
-meta-variable interpretation, duplicate it: @samp{$$}.
+@anchor{handling of undefined variables}
+@cindex expansion of undefined variables
+@cindex undefined variable, expansion
+If a string contains a reference to an undefined variable,
+@command{wydawca} will report an error and abort. To
+gracefully handle such cases, use the @dfn{default value construct},
+defined above.
-The exact set of defined meta-variables and their values depend on the
-context and are discussed in detail below.
+@FIXME{Implement the expand-undefined setting, similar to the one in
+rush}.
@@ -1498,10 +1514,8 @@ See below for a detailed description of these dictionary types.
Sets the query used for retrieving the data. The @var{string} is
-subject to meta-variable interpretation (@pxref{meta-interpretation}). The
-following meta-variables are defined:
+subject to variable expansion (@pxref{variable expansion}). The
+following variables are defined in this context:
@table @code
-@kwindex p
@kwindex project
-@item p
-@itemx project
+@item project
The system name of the project for which the triplet is
@@ -1511,2 +1525,3 @@ shortest initial prefix of that value, not containing slashes.
+@kwindex spool
@item spool
@@ -1515,2 +1530,3 @@ shortest initial prefix of that value, not containing slashes.
+@kwindex url
@item url
@@ -1519,2 +1535,3 @@ of the @code{spool} block (@pxref{spool, url}).
+@kwindex dir
@item dir
@@ -1523,12 +1540,12 @@ files are going to be uploaded.
-@item dest-dir
+@kwindex dest_dir
+@item dest_dir
Spool destination directory (@pxref{spool, destination}).
-@item source-dir
+@kwindex source_dir
+@item source_dir
Spool source directory (@pxref{spool, source}).
-@kwindex u
@kwindex user
-@item u
-@itemx user
+@item user
@itemx user:name
@@ -2012,4 +2029,5 @@ spool @var{tag} @{
The @var{tag} argument defines a unique identifier for this spool. It
-will be used in log messages, timers (@pxref{spool-timers}) and in
-meta-variable interpretation (@pxref{meta-interpretation}).
+will be used in log messages, timers (@pxref{spool-timers}) and is
+available for variable expansion (@pxref{variable expansion}) as the
+@samp{$spool} variable.
@end deffn
@@ -2030,3 +2048,3 @@ description of this feature.
Defines download @acronym{URL}, associated with this spool. Its value
-may be used as @samp{$@{url@}} meta-variable in mail notifications.
+may be used as the variable @samp{$url} in mail notifications.
@end deffn
@@ -2217,7 +2235,7 @@ In case of non-zero return, the script may return additional
diagnostics on the standard output. This diagnostics will be
-available for use in notification messages via the @samp{check:diagn}
-meta-variable.
+available for use in notification messages via the @samp{$check:diagn}
+variable.
Additionally, the actual return code of the script, in decimal, is
-available in the @samp{check:result} meta-variable. If the script
+available in the @samp{$check:result} variable. If the script
terminates on a signal, the value of this variable is
@@ -2778,3 +2796,3 @@ mailer "|/bin/nullmail localhost -F$@{sender@} $@{rcpt@}"
Each notification message is build from a message template, by
-expanding meta-variables (@pxref{meta-interpretation}) within it.
+expanding variables (@pxref{variable expansion}) within it.
The message text may be specified either in place within the
@@ -2876,4 +2894,4 @@ The statistics message is sent to addresses configured by
-@cindex meta-variables in admin notifications
-The meta-variables available for use in statistics reports are:
+@cindex variables in admin notifications
+The variables available for use in statistics reports are:
@@ -2914,3 +2932,3 @@ triplets.
@kwindex stat:check-failures
-@item stat:check-failures @tab Number of verification failures
+@item stat:check_failures @tab Number of verification failures
(@pxref{verification}).
@@ -3062,5 +3080,5 @@ template, or a reference to a template previously defined by a
root) where the files where uploaded.
-@kwindex dest-dir
+@kwindex dest_dir
@item dest-dir @tab Value of the @code{destination} keyword.
-@kwindex source-dir
+@kwindex source_dir
@item source-dir @tab Value of the @code{source} keyword.
@@ -3084,3 +3102,3 @@ $@{triplet:ls:dir@}
@kwindex triplet:ls:upload
-@item triplet:upload @tab Listing of the uploaded files (see below).
+@item triplet:ls:upload @tab Listing of the uploaded files (see below).
@kwindex triplet:dist
@@ -3095,3 +3113,3 @@ $@{triplet:ls:dir@}
@item user:name @tab System name of the user who uploaded the triplet.
-@kwindex user:real-name
+@kwindex user:real_name
@item user:real-name @tab Real name of the user who uploaded the triplet.
@@ -3166,10 +3184,4 @@ example, here is a possible @code{$@{triplet:ls:full@}} listing:
- The following example shows how to configure success notification
-for the user. Notice the use of the @samp{$-} after
-@samp{$@{triplet:ls:upload@}}: it removes the newline character after
-it and thus allows for more natural indentation of the next
-line. Without it, the expanded message would have contained two
-newlines after the full listing: one produced by
-@samp{$@{triplet:ls:upload@}} and the second one taken verbatim from
-the message template.
+ The example in the following subsection shows how to configure
+success notification for the user.
@@ -3210,3 +3222,3 @@ module-init mailutils @{
symlinks removed ................... $@{stat:rmsymlinks@}
- verification failures .............. $@{stat:check-failures@}
+ verification failures .............. $@{stat:check_failures@}
@@ -3249,3 +3261,3 @@ notify-event @{
- $@{triplet:ls:upload@}$-
+ $@{triplet:ls:upload@}
@@ -3326,3 +3338,3 @@ symlinks created: $@{stat:symlinks@}
symlinks removed: $@{stat:rmsymlinks@}
-check failures: $@{stat:check-failures@}
+check failures: $@{stat:check_failures@}
EOT;

Return to:

Send suggestions and report system problems to the System administrator.