<term><command>start <replaceable>PATTERN</replaceable>…</command></term>
<listitem>
- <para>Start (activate) one or more units specified on the
- command line.</para>
-
- <para>Note that glob patterns operate on the set of primary names of units currently in memory. Units which
- are not active and are not in a failed state usually are not in memory, and will not be matched by any
- pattern. In addition, in case of instantiated units, systemd is often unaware of the instance name until
- the instance has been started. Therefore, using glob patterns with <command>start</command> has limited
- usefulness. Also, secondary alias names of units are not considered.</para>
+ <para>Start (activate) one or more units specified on the command line.</para>
+
+ <para>Note that unit glob patterns expand to names of units currently in memory. Units which are
+ not active and are not in a failed state usually are not in memory, and will not be matched by
+ any pattern. In addition, in case of instantiated units, systemd is often unaware of the instance
+ name until the instance has been started. Therefore, using glob patterns with
+ <command>start</command> has limited usefulness. Also, secondary alias names of units are not
+ considered.</para>
+
+ <para>Option <option>--all</option> may be used to also operate on inactive units which are
+ referenced by other loaded units. Note that this is not the same as operating on "all" possible
+ units, because as the previous paragraph describes, such a list is ill-defined. Nevertheless,
+ <command>systemctl start --all <replaceable>GLOB</replaceable></command> may be useful if all the
+ units that should match the pattern are pulled in by some target which is known to be loaded.
+ </para>
</listitem>
</varlistentry>
<varlistentry>
return c;
}
-static int expand_names(sd_bus *bus, char **names, const char* suffix, char ***ret) {
+static int expand_names(sd_bus *bus, char **names, const char* suffix, char ***ret, bool *ret_expanded) {
_cleanup_strv_free_ char **mangled = NULL, **globs = NULL;
char **name;
int r, i;
/* Query the manager only if any of the names are a glob, since
* this is fairly expensive */
- if (!strv_isempty(globs)) {
+ bool expanded = !strv_isempty(globs);
+ if (expanded) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_free_ UnitInfo *unit_infos = NULL;
size_t allocated, n;
}
}
+ if (ret_expanded)
+ *ret_expanded = expanded;
+
*ret = TAKE_PTR(mangled);
return 0;
}
(void) pager_open(arg_pager_flags);
- r = expand_names(bus, strv_skip(argv, 1), ".socket", &sockets_with_suffix);
+ r = expand_names(bus, strv_skip(argv, 1), ".socket", &sockets_with_suffix, NULL);
if (r < 0)
return r;
(void) pager_open(arg_pager_flags);
- r = expand_names(bus, strv_skip(argv, 1), ".timer", &timers_with_suffix);
+ r = expand_names(bus, strv_skip(argv, 1), ".timer", &timers_with_suffix, NULL);
if (r < 0)
return r;
if (!names)
return log_oom();
} else {
- r = expand_names(bus, strv_skip(argv, 1), suffix, &names);
+ bool expanded;
+
+ r = expand_names(bus, strv_skip(argv, 1), suffix, &names, &expanded);
if (r < 0)
return log_error_errno(r, "Failed to expand names: %m");
+
+ if (!arg_all && expanded && streq(job_type, "start") && !arg_quiet) {
+ log_warning("Warning: %ssystemctl start called with a glob pattern.%s",
+ ansi_highlight_red(),
+ ansi_normal());
+ log_notice("Hint: unit globs expand to loaded units, so start will usually have no effect.\n"
+ " Passing --all will also load units which are pulled in by other units.\n"
+ " See systemctl(1) for more details.");
+ }
}
if (!arg_no_block) {
if (r < 0)
return r;
- r = expand_names(bus, args, NULL, &names);
+ r = expand_names(bus, args, NULL, &names, NULL);
if (r < 0)
return log_error_errno(r, "Failed to expand names: %m");
if (streq(arg_job_mode, "fail"))
kill_who = strjoina(arg_kill_who, "-fail");
- r = expand_names(bus, strv_skip(argv, 1), NULL, &names);
+ r = expand_names(bus, strv_skip(argv, 1), NULL, &names, NULL);
if (r < 0)
return log_error_errno(r, "Failed to expand names: %m");
return log_oom();
}
- r = expand_names(bus, strv_skip(argv, 1), NULL, &names);
+ r = expand_names(bus, strv_skip(argv, 1), NULL, &names, NULL);
if (r < 0)
return log_error_errno(r, "Failed to expand names: %m");
if (!strv_isempty(patterns)) {
_cleanup_strv_free_ char **names = NULL;
- r = expand_names(bus, patterns, NULL, &names);
+ r = expand_names(bus, patterns, NULL, &names, NULL);
if (r < 0)
return log_error_errno(r, "Failed to expand names: %m");
if (r < 0)
return r;
- r = expand_names(bus, strv_skip(argv, 1), NULL, &names);
+ r = expand_names(bus, strv_skip(argv, 1), NULL, &names, NULL);
if (r < 0)
return log_error_errno(r, "Failed to expand names: %m");
polkit_agent_open_maybe();
- r = expand_names(bus, strv_skip(argv, 1), NULL, &names);
+ r = expand_names(bus, strv_skip(argv, 1), NULL, &names, NULL);
if (r < 0)
return log_error_errno(r, "Failed to expand names: %m");
if (r < 0)
return r;
- r = expand_names(bus, strv_skip(argv, 1), NULL, &names);
+ r = expand_names(bus, strv_skip(argv, 1), NULL, &names, NULL);
if (r < 0)
return log_error_errno(r, "Failed to expand names: %m");