[master] 7ae7f9a06 Add a "-a" append flag to filewrite
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jul 4 10:11:08 UTC 2022
commit 7ae7f9a0613eba366d1a008f566f0cdf71db5693
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jul 4 10:10:07 2022 +0000
Add a "-a" append flag to filewrite
diff --git a/bin/varnishtest/vtc_misc.c b/bin/varnishtest/vtc_misc.c
index 345170b89..8c90cf438 100644
--- a/bin/varnishtest/vtc_misc.c
+++ b/bin/varnishtest/vtc_misc.c
@@ -250,7 +250,9 @@ cmd_shell(CMD_ARGS)
*
* Write strings to file
*
- * filewrite /somefile "Hello" " " "World\n"
+ * filewrite [-a] /somefile "Hello" " " "World\n"
+ *
+ * The -a flag opens the file in append mode.
*
*/
@@ -259,14 +261,19 @@ cmd_filewrite(CMD_ARGS)
{
FILE *fo;
int n;
+ const char *mode = "w";
(void)priv;
if (av == NULL)
return;
+ if (av[1] != NULL && !strcmp(av[1], "-a")) {
+ av++;
+ mode = "a";
+ }
if (av[1] == NULL)
vtc_fatal(vl, "Need filename");
- fo = fopen(av[1], "w");
+ fo = fopen(av[1], mode);
if (fo == NULL)
vtc_fatal(vl, "Cannot open %s: %s", av[1], strerror(errno));
for (n = 2; av[n] != NULL; n++)
More information about the varnish-commit
mailing list