diff options
-rw-r--r-- | src/pacman/pacman.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 6e5147c5..37472083 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -957,6 +957,29 @@ static int parseconfig(const char *file) return(_parseconfig(file, NULL, NULL)); } +/** print commandline to logfile + */ +static void cl_to_log(int argc, char* argv[]) +{ + size_t size = 0; + int i; + for(i = 0; i<argc; i++) { + size += strlen(argv[i]) + 1; + } + char *cl_text = malloc(size); + if(!cl_text) + return; + char *p = cl_text; + for(i = 0; i<argc-1; i++) { + strcpy(p, argv[i]); + p += strlen(argv[i]); + *p++ = ' '; + } + strcpy(p, argv[i]); + alpm_logaction("Running '%s'\n", cl_text); + free(cl_text); +} + /** Main function. * @param argc argc * @param argv argv @@ -1083,6 +1106,11 @@ int main(int argc, char *argv[]) cleanup(EXIT_FAILURE); } + /* Log commandline */ + if(needs_root()) { + cl_to_log(argc, argv); + } + /* start the requested operation */ switch(config->op) { case PM_OP_REMOVE: |