mirror of
https://github.com/systemd/systemd.git
synced 2026-11-06 05:17:24 +00:00
hostnamectl: say that tags can be removed by glob
This commit is contained in:
1 parent
bd80a56ebd
commit
d73ba670fc
2 files changed
+23
-7
No files matched your search
+9
-6
@@ -180,12 +180,15 @@
|
||||
<para>Alternatively, each argument may be prefixed with <literal>+</literal> or <literal>-</literal>
|
||||
to incrementally update the configured tags rather than replacing them: an argument prefixed with
|
||||
<literal>+</literal> adds all of its (colon-separated) tags to the list, one prefixed with
|
||||
<literal>-</literal> removes them. For example, <command>hostnamectl tags +foo:bar -quux:ooo</command>
|
||||
adds the tags <literal>foo</literal> and <literal>bar</literal> and removes <literal>quux</literal>
|
||||
and <literal>ooo</literal>. The prefix applies to the whole argument, i.e. to every tag listed within
|
||||
it. Adding a <literal><replaceable>key</replaceable>=<replaceable>value</replaceable></literal> tag
|
||||
replaces any value previously assigned to the same key. Prefixed and unprefixed arguments may not be
|
||||
combined in a single invocation.</para>
|
||||
<literal>-</literal> specifies a removal pattern. For example, <command>hostnamectl tags +foo:bar
|
||||
-quux:ooo=*</command> adds the tags <literal>foo</literal> and <literal>bar</literal> and removes
|
||||
<literal>quux</literal> and any assignment of <literal>ooo=</literal>. The prefix applies to the
|
||||
whole argument, i.e. to every tag listed within it. Adding a
|
||||
<literal><replaceable>key</replaceable>=<replaceable>value</replaceable></literal> tag replaces any
|
||||
value previously assigned to the same key. Prefixed and unprefixed arguments may not be combined in a
|
||||
single invocation. Removal patterns may use shell-style globbing to remove any matching tags,
|
||||
<citerefentry project='man-pages'><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
|
||||
</para>
|
||||
|
||||
<para>If <option>--apply</option> is specified, no <replaceable>TAG</replaceable> arguments may be
|
||||
given. Instead, <filename>systemd-hostnamed</filename> is asked to apply the tag configuration
|
||||
|
||||
@@ -474,7 +474,20 @@ testcase_tags() {
|
||||
hostnamectl tags +foo=b
|
||||
assert_eq "$(hostnamectl tags)" "foo:foo=b"
|
||||
grep -x "TAGS=foo:foo=b" /etc/machine-info >/dev/null
|
||||
hostnamectl tags alpha:beta:quux
|
||||
|
||||
# A '*' suffix on a tag to remove removes all tags with that prefix, before tags are added.
|
||||
hostnamectl tags company.x:company.bar=old:companyfoo:other
|
||||
hostnamectl tags -- '-company.*' +company.foo:company.bar=waldo
|
||||
assert_eq "$(hostnamectl tags)" "company.bar=waldo:company.foo:companyfoo:other"
|
||||
hostnamectl tags -- '-company.*:other' -companyfoo +new
|
||||
assert_eq "$(hostnamectl tags)" "new"
|
||||
hostnamectl tags new:k=1:kx=2:kk:k
|
||||
hostnamectl tags -- '-k=*'
|
||||
assert_eq "$(hostnamectl tags)" "k:kk:kx=2:new"
|
||||
# The '*' suffix is only allowed for removal
|
||||
(! hostnamectl tags -- '+foo*')
|
||||
(! hostnamectl tags -- 'foo*')
|
||||
assert_eq "$(hostnamectl tags)" "k:kk:kx=2:new"
|
||||
|
||||
# Plain and prefixed arguments may not be mixed.
|
||||
(! hostnamectl tags foo +bar)
|
||||
|
||||
Reference in new issue
Block a user