diff options
-rw-r--r-- | NEWS | 46 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | doc/pies.texi | 212 | ||||
-rw-r--r-- | lib/envop.c | 14 | ||||
-rw-r--r-- | lib/envop.h | 2 | ||||
-rw-r--r-- | src/pies.c | 10 | ||||
-rw-r--r-- | src/progman.c | 7 | ||||
-rw-r--r-- | tests/env.at | 72 | ||||
-rw-r--r-- | tests/envop.at | 23 |
9 files changed, 361 insertions, 27 deletions
@@ -1,10 +1,10 @@ | |||
1 | GNU Pies NEWS -- history of user-visible changes. 2019-05-31 | 1 | GNU Pies NEWS -- history of user-visible changes. 2019-06-03 |
2 | See the end of file for copying conditions. | 2 | See the end of file for copying conditions. |
3 | 3 | ||
4 | Please send Pies bug reports to <bug-pies@gnu.org> or | 4 | Please send Pies bug reports to <bug-pies@gnu.org> or |
5 | <bug-pies@gnu.org.ua> | 5 | <bug-pies@gnu.org.ua> |
6 | 6 | ||
7 | Version 1.3.90 (git) | 7 | Version 1.3.91 (git) |
8 | 8 | ||
9 | * New option --no-init | 9 | * New option --no-init |
10 | 10 | ||
@@ -38,7 +38,41 @@ contains redirections, pipes, etc. E.g. | |||
38 | 38 | ||
39 | * Improved cyclic dependency diagnostics | 39 | * Improved cyclic dependency diagnostics |
40 | 40 | ||
41 | * Fix a bug in 'env' statement | 41 | * New 'env' statement |
42 | |||
43 | The 'env' statement has been re-implemented as a compound statement. | ||
44 | It can contain the following sub-statements: | ||
45 | |||
46 | ** clear yes | ||
47 | Clears the environment | ||
48 | |||
49 | ** keep NAME | ||
50 | Keeps the variable NAME when clearing the environment. Implies | ||
51 | "clear yes". NAME can be a globbing pattern, in which case all | ||
52 | variables matching the pattern are retained. | ||
53 | |||
54 | ** set "NAME=VALUE" | ||
55 | Sets the environment variable for the component. VALUE is subject | ||
56 | to variable expansion. | ||
57 | |||
58 | ** unset NAME | ||
59 | Unsets the variable. NAME can be a globbing pattern, in which case all | ||
60 | variables matching the pattern are unset. | ||
61 | |||
62 | Example: | ||
63 | |||
64 | env { | ||
65 | clear yes | ||
66 | keep PATH | ||
67 | keep MANPATH | ||
68 | keep "LC_*" | ||
69 | set "MANPATH=$MANPATH${MANPATH:+:}/usr/local/man" | ||
70 | } | ||
71 | |||
72 | * Legacy 'env' statement. | ||
73 | |||
74 | Support for the old one-line syntax of "env" is retained for | ||
75 | backward compatibility. | ||
42 | 76 | ||
43 | Previous versions applied unnecessary word splitting if given a | 77 | Previous versions applied unnecessary word splitting if given a |
44 | single argument. This is now fixed, so that e.g. the following | 78 | single argument. This is now fixed, so that e.g. the following |
@@ -47,6 +81,12 @@ X to have the value "foo bar": | |||
47 | 81 | ||
48 | env "X=foo bar" | 82 | env "X=foo bar" |
49 | 83 | ||
84 | * New environment variable available in commands started from return-code | ||
85 | |||
86 | Programs started via "exec" statement in the "return-code" block | ||
87 | obtain the PID of the master pies process in environment variable | ||
88 | PIES_MASTER_PID. | ||
89 | |||
50 | 90 | ||
51 | Version 1.3, 2016-10-01 | 91 | Version 1.3, 2016-10-01 |
52 | 92 | ||
diff --git a/configure.ac b/configure.ac index a3c0b34..ccfd9fc 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -15,7 +15,7 @@ | |||
15 | # along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | AC_PREREQ([2.63]) | 17 | AC_PREREQ([2.63]) |
18 | AC_INIT([GNU Pies], [1.3.90], [bug-pies@gnu.org.ua]) | 18 | AC_INIT([GNU Pies], [1.3.91], [bug-pies@gnu.org.ua]) |
19 | AC_CONFIG_SRCDIR([src/pies.h]) | 19 | AC_CONFIG_SRCDIR([src/pies.h]) |
20 | AC_CONFIG_AUX_DIR([build-aux]) | 20 | AC_CONFIG_AUX_DIR([build-aux]) |
21 | AC_CONFIG_HEADERS([config.h]) | 21 | AC_CONFIG_HEADERS([config.h]) |
diff --git a/doc/pies.texi b/doc/pies.texi index b77a40c..ccb9f0e 100644 --- a/doc/pies.texi +++ b/doc/pies.texi | |||
@@ -122,6 +122,7 @@ Component Statement | |||
122 | * Prerequisites:: | 122 | * Prerequisites:: |
123 | * Component Privileges:: | 123 | * Component Privileges:: |
124 | * Resources:: | 124 | * Resources:: |
125 | * Environment:: | ||
125 | * Actions Before Startup:: | 126 | * Actions Before Startup:: |
126 | * Exit Actions:: | 127 | * Exit Actions:: |
127 | * Output Redirectors:: | 128 | * Output Redirectors:: |
@@ -712,7 +713,7 @@ compatibility with the @sc{c} preprocessor. | |||
712 | @end table | 713 | @end table |
713 | 714 | ||
714 | @node Component Statement | 715 | @node Component Statement |
715 | @section Component Statement | 716 | @section The @code{component} Statement |
716 | @kwindex component | 717 | @kwindex component |
717 | 718 | ||
718 | @deffn {Config} component | 719 | @deffn {Config} component |
@@ -937,6 +938,7 @@ substatements. | |||
937 | * Prerequisites:: | 938 | * Prerequisites:: |
938 | * Component Privileges:: | 939 | * Component Privileges:: |
939 | * Resources:: | 940 | * Resources:: |
941 | * Environment:: | ||
940 | * Actions Before Startup:: | 942 | * Actions Before Startup:: |
941 | * Exit Actions:: | 943 | * Exit Actions:: |
942 | * Output Redirectors:: | 944 | * Output Redirectors:: |
@@ -1038,7 +1040,122 @@ Set the umask. The @var{number} must be an octal value not greater | |||
1038 | than @samp{777}. The default umask is inherited at startup. | 1040 | than @samp{777}. The default umask is inherited at startup. |
1039 | @end deffn | 1041 | @end deffn |
1040 | 1042 | ||
1041 | @deffn {Config: component} env @var{args} | 1043 | @deffn {Config: component} max-instances @var{n} |
1044 | Sets the maximum number of simultaneously running instances of this | ||
1045 | component. | ||
1046 | @end deffn | ||
1047 | |||
1048 | @node Environment | ||
1049 | @subsection Environment | ||
1050 | Normally all components inherit the environment of the master | ||
1051 | @command{pies} process. You can modify this environment using | ||
1052 | the @code{env} statement. It has two variants: @dfn{compound} and @dfn{legacy}. | ||
1053 | The legacy one-line statement was used in @command{pies} versions | ||
1054 | up to 1.3 and is still retained for backward compatibility. It is | ||
1055 | described in @ref{env legacy syntax}. This subsection describes the | ||
1056 | modern compount syntax. | ||
1057 | |||
1058 | @deffn {Config: component} env @{ ... @} | ||
1059 | The compound @code{env} statement has the following syntax: | ||
1060 | |||
1061 | @example | ||
1062 | @group | ||
1063 | env @{ | ||
1064 | clear @var{bool}; | ||
1065 | keep @var{pattern}; | ||
1066 | set "@var{name}=@var{value}"; | ||
1067 | unset @var{pattern}; | ||
1068 | @} | ||
1069 | @end group | ||
1070 | @end example | ||
1071 | @end deffn | ||
1072 | |||
1073 | Statements inside the @code{env} block define operations that | ||
1074 | modify the environment. The @code{clear} and @code{keep} statements | ||
1075 | are executed first. Then, the @code{set} and @code{unset} statements | ||
1076 | are applied in the order of their appearance in the configuration. | ||
1077 | |||
1078 | @deffn {env} clear @var{bool} | ||
1079 | If @var{bool} is @samp{yes}, all environment variables will be cleared | ||
1080 | (unset). The resulting environment will be empty, unless one or more | ||
1081 | @code{keep} statements are also given (see below). The @code{clear} | ||
1082 | statement is always executed first. | ||
1083 | @end deffn | ||
1084 | |||
1085 | @deffn {env} keep @var{pattern} | ||
1086 | Declares variables matching @var{pattern} (a globbing pattern) as | ||
1087 | exempt from clearing. This statement implies @code{clear}. | ||
1088 | |||
1089 | For example, the following configuration fragment removes from the | ||
1090 | environment all variables except @samp{HOME}, @samp{USER}, | ||
1091 | @samp{PATH}, and variables beginning with @samp{LC_}: | ||
1092 | |||
1093 | @example | ||
1094 | @group | ||
1095 | env @{ | ||
1096 | clear yes; | ||
1097 | keep HOME; | ||
1098 | keep USER; | ||
1099 | keep PATH; | ||
1100 | keep "LC_*"; | ||
1101 | @} | ||
1102 | @end group | ||
1103 | @end example | ||
1104 | @end deffn | ||
1105 | |||
1106 | @deffn {env} keep "@var{name}=@var{value}" | ||
1107 | Retains the variable @var{name}, if it has the given value. Note, that | ||
1108 | the argument must be quoted. | ||
1109 | @end deffn | ||
1110 | |||
1111 | @deffn {env} set "@var{name}=@var{value}" | ||
1112 | Assigns @var{value} to environment variable @var{name}. The value is | ||
1113 | subject to @dfn{variable expansion} using the same syntax as in shell. | ||
1114 | The @code{set} and @code{unset} (see below) statements are executed in | ||
1115 | order of their appearance. For example | ||
1116 | |||
1117 | @example | ||
1118 | @group | ||
1119 | env @{ | ||
1120 | set "MYLIB=$HOME/lib"; | ||
1121 | set "LD_LIBRARY_PATH=$LD_LIBRARY_PATH$@{LD_LIBRARY_PATH:+:@}$MYLIB"; | ||
1122 | @} | ||
1123 | @end group | ||
1124 | @end example | ||
1125 | @end deffn | ||
1126 | |||
1127 | @deffn {env} unset @var{pattern} | ||
1128 | Unset environment variables matching @var{pattern}. The following | ||
1129 | will unset the @env{LOGIN} variable: | ||
1130 | |||
1131 | @example | ||
1132 | unset LOGIN; | ||
1133 | @end example | ||
1134 | |||
1135 | @noindent | ||
1136 | The following will unset all variables starting with @samp{LD_}: | ||
1137 | |||
1138 | @example | ||
1139 | unset "LD_*"; | ||
1140 | @end example | ||
1141 | |||
1142 | @noindent | ||
1143 | Notice, that patterns containing wildcard characters must be quoted. | ||
1144 | @end deffn | ||
1145 | |||
1146 | @menu | ||
1147 | * env legacy syntax:: | ||
1148 | @end menu | ||
1149 | |||
1150 | @node env legacy syntax | ||
1151 | @subsubsection @code{env}: legacy syntax. | ||
1152 | Up to version 1.3 @command{pies} implemented the one-line variant of | ||
1153 | the @code{env} statement. The use of this legacy syntax is | ||
1154 | discouraged. It is supported for backward compatibility on |