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
@@ -728,52 +728,68 @@ example above:
728@end group 728@end group
729@end smallexample 729@end smallexample
730 730
731@anchor{meta-interpretation} 731@anchor{variable expansion}
732@cindex meta-interpretation 732@cindex variable expansion
733@cindex meta-variables 733@cindex variables
734Depending on the context, the contents of a quoted string may be 734Depending on the context, the quoted string may be subject to
735subject to @dfn{meta-variable interpretation}. During this process, 735@dfn{variable expansion}.
736any sequence
737 736
738@smallexample 737During variable expansion, references to variables
739$@{@var{var}@} 738in the string are replaced with their actual values. A variable
740@end smallexample 739reference has two basic forms:
741 740
742@noindent 741@example
743where @var{var} is the name of a defined meta-variable, is replaced with 742 $@var{v}
744the value of the variable. This sequence is called @dfn{meta- 743 $@{@var{v}@}
745reference}. For example, if the meta-variable @samp{user} has the 744@end example
746value @samp{smith}, then the string
747
748@smallexample
749"where user = '$@{user@}'"
750@end smallexample
751 745
752@noindent 746@noindent
753becomes 747where @var{v} is the variable name. The notation in curly braces
748serves several purposes. First, it should be used if the variable
749reference is immediately followed by an alphanumeric symbol, which
750will otherwise be considered part of it (as in @samp{$@{home@}dir}).
751Secondly, this form allows for specifying the action to take if the
752variable is undefined or expands to an empty value.
754 753
755@smallexample 754The following special forms are recognized:
756"where user = 'smith'"
757@end smallexample
758
759If the name of the variable consists of a single character, the curly
760braces around it may be omitted. Thus, @code{$@{u@}} and @code{$u} are
761equivalent.
762 755
763If @var{var} is not defined, the meta-reference is left unchanged. 756@table @asis
757@item $@{@var{variable}:-@var{word}@}
758@dfn{Use Default Values}. If @var{variable} is unset or null, the expansion
759of @var{word} is substituted. Otherwise, the value of @var{variable} is
760substituted.
761
762@item $@{@var{variable}:=@var{word}@}
763@dfn{Assign Default Values}. If @var{variable} is unset or null, the
764expansion of @var{word} is assigned to variable. The value of
765@var{variable} is then substituted.
766
767The assigned value remains in effet during expansion of the current string.
768
769@item $@{@var{variable}:?@var{word}@}
770@dfn{Display Error if Null or Unset}. If @var{variable} is null or unset,
771the expansion of @var{word} (or a message to that effect if @var{word} is
772not present) is output to the current logging channel. Otherwise, the
773value of @var{variable} is substituted.
774
775@item $@{@var{variable}:+@var{word}@}
776@dfn{Use Alternate Value}. If @var{variable} is null or unset, nothing is
777substituted, otherwise the expansion of @var{word} is substituted.
778@end table
764 779
765The special sequence @samp{$-} causes removal of it and any character 780These constructs test for a variable that is unset or null. Omitting
766following it. Most often it is used as a next-to-last character 781the colon results in a test only for a variable that is unset.
767on a line, right before the newline. In this position it causes the
768removal of the trailing newline, similar to @samp{dnl} in @command{m4}.
769@xref{listings, Triplet Listings}, for a detailed description and
770examples of @samp{$-} use.
771 782
772To insert a literal @samp{$} character in a string that is subject to 783@anchor{handling of undefined variables}
773meta-variable interpretation, duplicate it: @samp{$$}. 784@cindex expansion of undefined variables
785@cindex undefined variable, expansion
786If a string contains a reference to an undefined variable,
787@command{wydawca} will report an error and abort. To
788gracefully handle such cases, use the @dfn{default value construct},
789defined above.
774 790
775The exact set of defined meta-variables and their values depend on the 791@FIXME{Implement the expand-undefined setting, similar to the one in
776context and are discussed in detail below. 792rush}.
777 793
778@anchor{here-document} 794@anchor{here-document}
779@item Here-document 795@item Here-document
@@ -1496,41 +1512,42 @@ See below for a detailed description of these dictionary types.
1496@anchor{query} 1512@anchor{query}
1497@deffn {Config: dictionary} query string 1513@deffn {Config: dictionary} query string
1498Sets the query used for retrieving the data. The @var{string} is 1514Sets the query used for retrieving the data. The @var{string} is
1499subject to meta-variable interpretation (@pxref{meta-interpretation}). The 1515subject to variable expansion (@pxref{variable expansion}). The
1500following meta-variables are defined: 1516following variables are defined in this context:
1501 1517
1502@table @code 1518@table @code
1503@kwindex p
1504@kwindex project 1519@kwindex project
1505@item p 1520@item project
1506@itemx project
1507 The system name of the project for which the triplet is 1521 The system name of the project for which the triplet is
1508submitted. It is defined as the value of directive 1522submitted. It is defined as the value of directive
1509@code{directory}, or, in case this value contains slashes, the 1523@code{directory}, or, in case this value contains slashes, the
1510shortest initial prefix of that value, not containing slashes. 1524shortest initial prefix of that value, not containing slashes.
1511 1525
1526@kwindex spool
1512@item spool 1527@item spool
1513 The name of the distribution spool where this upload originates 1528 The name of the distribution spool where this upload originates
1514(@pxref{spool}). 1529(@pxref{spool}).
1515 1530
1531@kwindex url
1516@item url 1532@item url
1517 The @acronym{URL} of the spool, as set in the @code{url} statement 1533 The @acronym{URL} of the spool, as set in the @code{url} statement
1518of the @code{spool} block (@pxref{spool, url}). 1534of the @code{spool} block (@pxref{spool, url}).
1519 1535
1536@kwindex dir
1520@item dir 1537@item dir
1521Directory (relative to the project distribution root) where the 1538Directory (relative to the project distribution root) where the
1522files are going to be uploaded. 1539files are going to be uploaded.
1523 1540
1524@item dest-dir 1541@kwindex dest_dir
1542@item dest_dir
1525Spool destination directory (@pxref{spool, destination}). 1543Spool destination directory (@pxref{spool, destination}).
1526 1544
1527@item source-dir 1545@kwindex source_dir
1546@item source_dir
1528Spool source directory (@pxref{spool, source}). 1547Spool source directory (@pxref{spool, source}).
1529 1548
1530@kwindex u
1531@kwindex user 1549@kwindex user
1532@item u 1550@item user
1533@itemx user
1534@itemx user:name 1551@itemx user:name
1535 The system name of the user that submitted the triplet. This is 1552 The system name of the user that submitted the triplet. This is
1536defined only for @samp{project-owner} dictionaries. 1553defined only for @samp{project-owner} dictionaries.
@@ -2010,8 +2027,9 @@ spool @var{tag} @{
2010@end smallexample 2027@end smallexample
2011 2028
2012The @var{tag} argument defines a unique identifier for this spool. It 2029The @var{tag} argument defines a unique identifier for this spool. It
2013will be used in log messages, timers (@pxref{spool-timers}) and in 2030will be used in log messages, timers (@pxref{spool-timers}) and is
2014meta-variable interpretation (@pxref{meta-interpretation}). 2031available for variable expansion (@pxref{variable expansion}) as the
2032@samp{$spool} variable.
2015@end deffn 2033@end deffn
2016 2034
2017@deffn {Config: spool} alias list 2035@deffn {Config: spool} alias list
@@ -2028,7 +2046,7 @@ description of this feature.
2028 2046
2029@deffn {Config: spool} url string 2047@deffn {Config: spool} url string
2030Defines download @acronym{URL}, associated with this spool. Its value 2048Defines download @acronym{URL}, associated with this spool. Its value
2031may be used as @samp{$@{url@}} meta-variable in mail notifications. 2049may be used as the variable @samp{$url} in mail notifications.
2032@end deffn 2050@end deffn
2033 2051
2034@deffn {Config: spool} source dir 2052@deffn {Config: spool} source dir
@@ -2215,11 +2233,11 @@ notification}) is generated.
2215 2233
2216In case of non-zero return, the script may return additional 2234In case of non-zero return, the script may return additional
2217diagnostics on the standard output. This diagnostics will be 2235diagnostics on the standard output. This diagnostics will be
2218available for use in notification messages via the @samp{check:diagn} 2236available for use in notification messages via the @samp{$check:diagn}
2219meta-variable. 2237variable.
2220 2238
2221Additionally, the actual return code of the script, in decimal, is 2239Additionally, the actual return code of the script, in decimal, is
2222available in the @samp{check:result} meta-variable. If the script 2240available in the @samp{$check:result} variable. If the script
2223terminates on a signal, the value of this variable is 2241terminates on a signal, the value of this variable is
2224@samp{SIG+@var{n}}, where @var{n} is the signal number. 2242@samp{SIG+@var{n}}, where @var{n} is the signal number.
2225@end deffn 2243@end deffn
@@ -2776,7 +2794,7 @@ mailer "|/bin/nullmail localhost -F$@{sender@} $@{rcpt@}"
2776@cindex notification message template 2794@cindex notification message template
2777@cindex message template 2795@cindex message template