1.1 --- a/pre-inst/pre-inst.c Thu Jul 16 19:54:45 2020 +0100
1.2 +++ b/pre-inst/pre-inst.c Tue Apr 25 17:41:00 2023 +0100
1.3 @@ -48,12 +48,13 @@
1.4 #endif /* WIN32 */
1.5 #include "post.h"
1.6
1.7 -#ifdef WIN32
1.8 -/* Under WIN32, g_spawn requires a helper program which we'd rather avoid */
1.9 -#undef USE_G_SPAWN
1.10 -#else
1.11 +/*
1.12 + * Under WIN32, g_spawn may require a helper program which we'd rather avoid.
1.13 + * At least with glib 2.58, this isn't needed if g_spawn_sync() is used (or
1.14 + * G_SPAWN_DO_NOT_REAP_CHILD is specified), so we can now define USE_G_SPAWN
1.15 + * unconditionally.
1.16 + */
1.17 #define USE_G_SPAWN
1.18 -#endif
1.19
1.20 LUALIB_API int luaopen_posix(lua_State *L);
1.21
1.22 @@ -376,6 +377,7 @@
1.23 "Post command exited with code %ld",(long)rc);
1.24 return FALSE;
1.25 }
1.26 + fprintf(stderr,"post command exited normally\n");
1.27 return TRUE;
1.28 }
1.29
1.30 @@ -422,6 +424,29 @@
1.31 return TRUE;
1.32 }
1.33
1.34 +print_arguments(int argc,char **argv)
1.35 +{
1.36 + int i,j;
1.37 + for(i=0;i<argc;i++)
1.38 + {
1.39 + if (i)
1.40 + putchar(' ');
1.41 + if (strchr(argv[i],' ') || strchr(argv[i],'"') || strchr(argv[i],'\n'))
1.42 + {
1.43 + putchar('"');
1.44 + for(j=0;argv[i][j];j++)
1.45 + {
1.46 + if (strchr("$`\"\\\n",argv[i][j]))
1.47 + putchar('\\');
1.48 + putchar(argv[i][j]);
1.49 + }
1.50 + putchar('"');
1.51 + }
1.52 + else
1.53 + fputs(argv[i],stdout);
1.54 + }
1.55 +}
1.56 +
1.57 /*
1.58 * Run a command after completing request.
1.59 *
1.60 @@ -446,7 +471,6 @@
1.61 "--post: No command given");
1.62 return FALSE;
1.63 }
1.64 - printf("Running post command: %s\n",argv[1]);
1.65 if (!g_shell_parse_argv(argv[1],&post_argc,&post_argv,&tmp_error))
1.66 {
1.67 g_propagate_prefixed_error(error,tmp_error,"%s: ",argv[1]);
1.68 @@ -482,6 +506,9 @@
1.69 post_argv[i]=expanded;
1.70 }
1.71 }
1.72 + printf("Running post command: ");
1.73 + print_arguments(post_argc,post_argv);
1.74 + putchar('\n');
1.75 return pre_install_spawn_sync(post_argv,error);
1.76 }
1.77
1.78 @@ -593,7 +620,12 @@
1.79 }
1.80 }
1.81 if (post && post->argc>0)
1.82 + {
1.83 + printf("Running post command: ");
1.84 + print_arguments(post->argc,post->argv);
1.85 + putchar('\n');
1.86 pre_install_spawn_sync(post->argv,&error);
1.87 + }
1.88 else if (argv)
1.89 run_post(argc,argv,success,repository,&error);
1.90 if (post)