From: Ian Jackson <iwj@xenproject.org>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <iwj@xenproject.org>
Subject: [OSSTEST PATCH 1/7] target_editfile_kvp_replace: Support changing multiple keys
Date: Fri, 22 Jan 2021 15:55:57 +0000 [thread overview]
Message-ID: <20210122155603.23402-1-iwj@xenproject.org> (raw)
No functional change with existing callers.
Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
Osstest/TestSupport.pm | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 9362a865..d2558f31 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -769,25 +769,32 @@ sub teditfileex {
if $install;
}
-# Replace a Key=Value style line in a config file.
+# Replace Key=Value style line(s) in a config file.
#
# To be used as 3rd argument to target_editfile(_root) as:
# target_editfile_root($ho, "/path/to/a/file",
# sub { target_editfile_kvp_replace($key, $value) });
-sub target_editfile_kvp_replace ($$)
+sub target_editfile_kvp_replace
{
- my ($key,$value) = @_;
- my $prnow;
- $prnow= sub {
+ my (%kv) = @_;
+ my $prnow= sub {
+ my ($key) = @_;
+ my $value = $kv{$key};
+ return unless defined $value;
print ::EO "$key=$value\n" or die $!;
- $prnow= sub { };
+ delete $kv{$key};
};
while (<::EI>) {
- print ::EO or die $! unless m/^$key\b/;
- $prnow->() if m/^#$key/;
+ if (m/^\S+\b/ && exists $kv{$&}) {
+ $prnow->($&);
+ } else {
+ print ::EO or die $!;
+ }
}
print ::EO "\n" or die $!;
- $prnow->();
+ foreach my $key (sort keys %kv) {
+ $prnow->($key);
+ }
};
sub target_editfile_root ($$$;$$) { teditfileex('root',@_); }
--
2.20.1
next reply other threads:[~2021-01-22 15:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-22 15:55 Ian Jackson [this message]
2021-01-22 15:55 ` [OSSTEST PATCH 2/7] target_editfile_kvp_replace: Add a bit of logging Ian Jackson
2021-01-22 15:55 ` [OSSTEST PATCH 3/7] ts-xen-install: Rename $commons_config_file Ian Jackson
2021-01-22 15:56 ` [OSSTEST PATCH 4/7] ts-xen-install: Break out @commons_config Ian Jackson
2021-01-22 15:56 ` [OSSTEST PATCH 5/7] ts-xen-install: Honour xenstored target var Ian Jackson
2021-01-22 15:56 ` [OSSTEST PATCH 6/7] mfi-common: Provide stripy_rand Ian Jackson
2021-01-22 15:56 ` [OSSTEST PATCH 7/7] make-flight: Stripy xenstored Ian Jackson
2021-01-22 16:07 ` Andrew Cooper
2021-01-22 16:22 ` Ian Jackson
2021-01-22 16:24 ` Jürgen Groß
2021-01-22 16:26 ` Ian Jackson
2021-01-22 16:29 ` Jürgen Groß
2021-01-22 16:29 ` Andrew Cooper
2021-01-22 17:37 ` [OSSTEST PATCH 7/7] make-flight: Stripy xenstored [and 2 more messages] Ian Jackson
2021-01-22 17:52 ` Andrew Cooper
2021-01-28 14:26 ` Ian Jackson
2021-01-22 16:11 ` [OSSTEST PATCH 7/7] make-flight: Stripy xenstored Christian Lindig
2021-01-22 16:36 ` Andrew Cooper
2021-01-22 16:40 ` Edwin Torok
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210122155603.23402-1-iwj@xenproject.org \
--to=iwj@xenproject.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).