diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-07-24 14:14:47 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-07-24 14:27:11 +0300 |
commit | c047ed856d6d23137ef1df01c1297db36bad3f8c (patch) | |
tree | 1999db947cb5e38df8a85d314daa0eef7c7624d0 /doc/wydawca.texi | |
parent | 07ea006a31def46ba6ea936dbea366219152d9b6 (diff) | |
download | wydawca-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.texi | 156 |
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 |
734 | Depending on the context, the contents of a quoted string may be | 734 | Depending on the context, the quoted string may be subject to |
735 | subject to @dfn{meta-variable interpretation}. During this process, | 735 | @dfn{variable expansion}. |
736 | any sequence | ||
737 | 736 | ||
738 | @smallexample | 737 | During variable expansion, references to variables |
739 | $@{@var{var}@} | 738 | in the string are replaced with their actual values. A variable |
740 | @end smallexample | 739 | reference has two basic forms: |
741 | 740 | ||
742 | @noindent | 741 | @example |
743 | where @var{var} is the name of a defined meta-variable, is replaced with | 742 | $@var{v} |
744 | the value of the variable. This sequence is called @dfn{meta- | 743 | $@{@var{v}@} |
745 | reference}. For example, if the meta-variable @samp{user} has the | 744 | @end example |
746 | value @samp{smith}, then the string | ||
747 | |||
748 | @smallexample | ||
749 | "where user = '$@{user@}'" | ||
750 | @end smallexample | ||
751 | 745 | ||
752 | @noindent | 746 | @noindent |
753 | becomes | 747 | where @var{v} is the variable name. The notation in curly braces |
748 | serves several purposes. First, it should be used if the variable | ||
749 | reference is immediately followed by an alphanumeric symbol, which | ||
750 | will otherwise be considered part of it (as in @samp{$@{home@}dir}). | ||
751 | Secondly, this form allows for specifying the action to take if the | ||
752 | variable is undefined or expands to an empty value. | ||
754 | 753 | ||
755 | @smallexample | 754 | The following special forms are recognized: |
756 | "where user = 'smith'" | ||
757 | @end smallexample | ||
758 | |||
759 | If the name of the variable consists of a single character, the curly | ||
760 | braces around it may be omitted. Thus, @code{$@{u@}} and @code{$u} are | ||
761 | equivalent. | ||
762 | 755 | ||
763 | If @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 | ||
759 | of @var{word} is substituted. Otherwise, the value of @var{variable} is | ||
760 | substituted. | ||
761 | |||
762 | @item $@{@var{variable}:=@var{word}@} | ||
763 | @dfn{Assign Default Values}. If @var{variable} is unset or null, the | ||
764 | expansion of @var{word} is assigned to variable. The value of | ||
765 | @var{variable} is then substituted. | ||
766 | |||
767 | The 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, | ||
771 | the expansion of @var{word} (or a message to that effect if @var{word} is | ||
772 | not present) is output to the current logging channel. Otherwise, the | ||
773 | value 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 | ||
777 | substituted, otherwise the expansion of @var{word} is substituted. | ||
778 | @end table | ||
764 | 779 | ||
765 | The special sequence @samp{$-} causes removal of it and any character | 780 | These constructs test for a variable that is unset or null. Omitting |
766 | following it. Most often it is used as a next-to-last character | 781 | the colon results in a test only for a variable that is unset. |
767 | on a line, right before the newline. In this position it causes the | ||
768 | removal of the trailing newline, similar to @samp{dnl} in @command{m4}. | ||
769 | @xref{listings, Triplet Listings}, for a detailed description and | ||
770 | examples of @samp{$-} use. | ||
771 | 782 | ||
772 | To insert a literal @samp{$} character in a string that is subject to | 783 | @anchor{handling of undefined variables} |
773 | meta-variable interpretation, duplicate it: @samp{$$}. | 784 | @cindex expansion of undefined variables |
785 | @cindex undefined variable, expansion | ||
786 | If a string contains a reference to an undefined variable, | ||
787 | @command{wydawca} will report an error and abort. To | ||
788 | gracefully handle such cases, use the @dfn{default value construct}, | ||
789 | defined above. | ||
774 | 790 | ||
775 | The exact set of defined meta-variables and their values depend on the | 791 | @FIXME{Implement the expand-undefined setting, similar to the one in |
776 | context and are discussed in detail below. | 792 | rush}. |
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 |
1498 | Sets the query used for retrieving the data. The @var{string} is | 1514 | Sets the query used for retrieving the data. The @var{string} is |
1499 | subject to meta-variable interpretation (@pxref{meta-interpretation}). The | 1515 | subject to variable expansion (@pxref{variable expansion}). The |
1500 | following meta-variables are defined: | 1516 | following 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 |
1508 | submitted. It is defined as the value of directive | 1522 | submitted. 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 |
1510 | shortest initial prefix of that value, not containing slashes. | 1524 | shortest 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 |
1518 | of the @code{spool} block (@pxref{spool, url}). | 1534 | of the @code{spool} block (@pxref{spool, url}). |
1519 | 1535 | ||
1536 | @kwindex dir | ||
1520 | @item dir | 1537 | @item dir |
1521 | Directory (relative to the project distribution root) where the | 1538 | Directory (relative to the project distribution root) where the |
1522 | files are going to be uploaded. | 1539 | files are going to be uploaded. |
1523 | 1540 | ||
1524 | @item dest-dir | 1541 | @kwindex dest_dir |
1542 | @item dest_dir | ||
1525 | Spool destination directory (@pxref{spool, destination}). | 1543 | Spool destination directory (@pxref{spool, destination}). |
1526 | 1544 | ||
1527 | @item source-dir | 1545 | @kwindex source_dir |
1546 | @item source_dir | ||
1528 | Spool source directory (@pxref{spool, source}). | 1547 | Spool 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 |
1536 | defined only for @samp{project-owner} dictionaries. | 1553 | defined only for @samp{project-owner} dictionaries. |
@@ -2010,8 +2027,9 @@ spool @var{tag} @{ | |||
2010 | @end smallexample | 2027 | @end smallexample |
2011 | 2028 | ||
2012 | The @var{tag} argument defines a unique identifier for this spool. It | 2029 | The @var{tag} argument defines a unique identifier for this spool. It |
2013 | will be used in log messages, timers (@pxref{spool-timers}) and in | 2030 | will be used in log messages, timers (@pxref{spool-timers}) and is |
2014 | meta-variable interpretation (@pxref{meta-interpretation}). | 2031 | available 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 |
2030 | Defines download @acronym{URL}, associated with this spool. Its value | 2048 | Defines download @acronym{URL}, associated with this spool. Its value |
2031 | may be used as @samp{$@{url@}} meta-variable in mail notifications. | 2049 | may 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 | ||
2216 | In case of non-zero return, the script may return additional | 2234 | In case of non-zero return, the script may return additional |
2217 | diagnostics on the standard output. This diagnostics will be | 2235 | diagnostics on the standard output. This diagnostics will be |
2218 | available for use in notification messages via the @samp{check:diagn} | 2236 | available for use in notification messages via the @samp{$check:diagn} |
2219 | meta-variable. | 2237 | variable. |
2220 | 2238 | ||
2221 | Additionally, the actual return code of the script, in decimal, is | 2239 | Additionally, the actual return code of the script, in decimal, is |
2222 | available in the @samp{check:result} meta-variable. If the script | 2240 | available in the @samp{$check:result} variable. If the script |
2223 | terminates on a signal, the value of this variable is | 2241 | terminates 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 |