utils: Display bundled bwrap arguments one per line

This makes them easier to deal with when debugging. Otherwise, it's easy
for the bundled arguments to wrap across 50 or more lines, and with
linebreaks in arbitrary positions that becomes very hard to read.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2021-02-23 18:35:52 +00:00
committed by Alexander Larsson
parent f2b2a12f56
commit b13c8a76d2
3 changed files with 19 additions and 7 deletions

View File

@@ -347,10 +347,21 @@ flatpak_bwrap_bundle_args (FlatpakBwrap *bwrap,
fd = glnx_steal_fd (&args_tmpf.fd);
{
g_autofree char *commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata + start, end - start);
flatpak_debug2 ("bwrap --args %d = %s", fd, commandline);
}
flatpak_debug2 ("bwrap --args %d = ...", fd);
for (i = start; i < end; i++)
{
if (flatpak_argument_needs_quoting (bwrap->argv->pdata[i]))
{
g_autofree char *quoted = g_shell_quote (bwrap->argv->pdata[i]);
flatpak_debug2 (" %s", quoted);
}
else
{
flatpak_debug2 (" %s", (const char *) bwrap->argv->pdata[i]);
}
}
flatpak_bwrap_add_fd (bwrap, fd);
g_ptr_array_remove_range (bwrap->argv, start, end - start);

View File

@@ -593,6 +593,7 @@ GList *flatpak_list_extensions (GKeyFile *metakey,
const char *arch,
const char *branch);
gboolean flatpak_argument_needs_quoting (const char *arg);
char * flatpak_quote_argv (const char *argv[],
gssize len);
gboolean flatpak_file_arg_has_suffix (const char *arg,

View File

@@ -1412,8 +1412,8 @@ flatpak_switch_symlink_and_remove (const char *symlink_path,
return flatpak_fail (error, "flatpak_switch_symlink_and_remove looped too many times");
}
static gboolean
needs_quoting (const char *arg)
gboolean
flatpak_argument_needs_quoting (const char *arg)
{
while (*arg != 0)
{
@@ -1443,7 +1443,7 @@ flatpak_quote_argv (const char *argv[],
if (i != 0)
g_string_append_c (res, ' ');
if (needs_quoting (argv[i]))
if (flatpak_argument_needs_quoting (argv[i]))
{
g_autofree char *quoted = g_shell_quote (argv[i]);
g_string_append (res, quoted);