1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

Better error message with "-" is specified without stdin

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2013-02-02 19:58:50 +10:00
parent 5c5cdb0eb9
commit 7956441350

View File

@ -809,7 +809,8 @@ int main(int argc, char *argv[])
} }
/* we support reading targets from stdin if a cmdline parameter is '-' */ /* we support reading targets from stdin if a cmdline parameter is '-' */
if(!isatty(fileno(stdin)) && alpm_list_find_str(pm_targets, "-")) { if(alpm_list_find_str(pm_targets, "-")) {
if(!isatty(fileno(stdin))) {
size_t current_size = PATH_MAX; size_t current_size = PATH_MAX;
char *vdata, *line = malloc(current_size); char *vdata, *line = malloc(current_size);
@ -842,6 +843,7 @@ int main(int argc, char *argv[])
} }
} }
} }
/* check for memory exhaustion */ /* check for memory exhaustion */
if(!line) { if(!line) {
pm_printf(ALPM_LOG_ERROR, _("memory exhausted in argument parsing\n")); pm_printf(ALPM_LOG_ERROR, _("memory exhausted in argument parsing\n"));
@ -858,6 +860,11 @@ int main(int argc, char *argv[])
pm_printf(ALPM_LOG_ERROR, _("failed to reopen stdin for reading: (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to reopen stdin for reading: (%s)\n"),
strerror(errno)); strerror(errno));
} }
} else {
/* do not read stdin from terminal */
pm_printf(ALPM_LOG_ERROR, _("argument '-' specified without input on stdin\n"));
cleanup(1);
}
} }
/* parse the config file */ /* parse the config file */