If the filename contains strange or non-printable characters, then it's better to quote it rather than mess up the output. We had a report of a case where DOS line endings were used in a shebang plugin, like this:
#!/usr/sbin/nbdkit python\r\n What happens here is that Linux ran nbdkit with the parameter "python\r", resulting in the peculiar error message: $ /path/to/plugin.py -plugin.so: cannot open shared object file: No such file or directory The complete error message contained the literal '\r' character, resulting in the first part of the error being overwritten when printed. After this change, the error message becomes: $ ./nbdkit /path/to/plugin.py nbdkit: error: cannot open plugin "/home/rjones/d/nbdkit/plugins/python\r/.libs/nbdkit-python\r-plugin.so": /home/rjones/d/nbdkit/plugins/python\r/.libs/nbdkit-python\r-plugin.so: cannot open shared object file: No such file or directory which may be clearer. Reported-by: Mykola Ivanets Thanks: Eric Blake --- server/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/main.c b/server/main.c index f3cb604cbd..baea095680 100644 --- a/server/main.c +++ b/server/main.c @@ -1021,8 +1021,11 @@ failed_to_load_error (const char *what, const char *filename, const char *short_name) { - fprintf (stderr, "%s: error: cannot open %s '%s': %s\n", - program_name, what, filename, dlerror ()); + fprintf (stderr, "%s: error: cannot open %s \"", program_name, what); + c_string_quote (filename, stderr); + fprintf (stderr, "\": "); + c_string_quote (dlerror (), stderr); + fprintf (stderr, "\n"); if (short_name && is_possible_package_name (short_name)) { fprintf (stderr, "\n" -- 2.44.0 _______________________________________________ Libguestfs mailing list -- guestfs@lists.libguestfs.org To unsubscribe send an email to guestfs-le...@lists.libguestfs.org