This switch rings the terminal bell when user input is required. Obviously, it has no effect if --noconfirm is also passed. --- doc/pacman.8.txt | 3 +++ src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 3 +++ src/pacman/util.c | 15 +++++++++------ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 514f559..6e0617a 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -148,6 +148,9 @@ Options *\--arch* <arch>:: Specify an alternate architecture. +*\--bell*:: + Sound the terminal bell when input is required. + *\--cachedir* <dir>:: Specify an alternative package cache location (a typical default is +{localstatedir}/cache/pacman/pkg+). Multiple cache directories can be diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 7a7e9cf..463ae48 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -55,6 +55,7 @@ typedef struct __config_t { unsigned short checkspace; unsigned short usesyslog; unsigned short color; + unsigned short bell; double deltaratio; char *arch; char *print_format; @@ -201,7 +202,8 @@ enum { OP_VERBOSE, OP_DOWNLOADONLY, OP_REFRESH, - OP_ASSUMEINSTALLED + OP_ASSUMEINSTALLED, + OP_BELL }; /* clean method */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 94685a7..07282e7 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -221,6 +221,7 @@ static void usage(int op, const char * const myname) addlist(_(" --logfile <path> set an alternate log file\n")); addlist(_(" --noconfirm do not ask for any confirmation\n")); addlist(_(" --confirm always ask for confirmation\n")); + addlist(_(" --bell sound the terminal bell when input is required\n")); } list = alpm_list_msort(list, alpm_list_count(list), options_cmp); for(i = list; i; i = alpm_list_next(i)) { @@ -480,6 +481,7 @@ static int parsearg_global(int opt) case OP_CONFIRM: config->noconfirm = 0; break; + case OP_BELL: config->bell = 1; break; case OP_DBPATH: case 'b': free(config->dbpath); @@ -981,6 +983,7 @@ static int parseargs(int argc, char *argv[]) {"gpgdir", required_argument, 0, OP_GPGDIR}, {"dbonly", no_argument, 0, OP_DBONLY}, {"color", required_argument, 0, OP_COLOR}, + {"bell", no_argument, 0, OP_BELL}, {0, 0, 0, 0} }; diff --git a/src/pacman/util.c b/src/pacman/util.c index 5f331e8..9183047 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1396,13 +1396,14 @@ int multiselect_question(char *array, int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a selection (default=all)")); fprintf(stream, ": "); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); break; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fileno(stdin)); if(safe_fgets(response, response_len, stdin)) { @@ -1463,13 +1464,14 @@ int select_question(int count) fprintf(stream, "\n"); fprintf(stream, _("Enter a number (default=%d)"), preset); fprintf(stream, ": "); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); break; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fileno(stdin)); if(safe_fgets(response, sizeof(response), stdin)) { @@ -1517,13 +1519,14 @@ static int question(short preset, const char *format, va_list args) } fputs(config->colstr.nocolor, stream); - fflush(stream); if(config->noconfirm) { fprintf(stream, "\n"); return preset; + } else if(config->bell) { + fprintf(stream, "\a"); } - + fflush(stream); flush_term_input(fd_in); if(safe_fgets(response, sizeof(response), stdin)) { -- 2.6.2