[pacman-dev] [PATCH] remove isatty check before reading from stdin

Dan McGee dpmcgee at gmail.com
Sat Nov 24 13:37:25 EST 2012


On Sat, Nov 24, 2012 at 1:29 PM, Dave Reisner <d at falconindy.com> wrote:
> On Sat, Nov 24, 2012 at 01:15:17PM -0500, Andrew Gregory wrote:
>> The old behavior is undocumented and we already require the user
>> to explicitly request reading from stdin so we should oblige them
>> whether stdin is a tty or not.
>>
>> Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
>> ---
>>  src/pacman/pacman.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
>> index e86b5c7..d9de556 100644
>> --- a/src/pacman/pacman.c
>> +++ b/src/pacman/pacman.c
>> @@ -809,7 +809,7 @@ int main(int argc, char *argv[])
>>       }
>>
>>       /* 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, "-")) {
>
> Just for fun, this would make a package by the name of '-' (which is a
> valid name) only accessible via something like:
>
>   pacman -Si - <<<-
>
> Alternatively, I think it'd be a little weird to see pacman just "hang"
> if you had a random '-' as an argument and pacman just hung.
>
> Is there anything this patch actually fixes?

I also worry about how easy it is to use '-' instead of '--' if you
are trying to prevent interpretation as an arg; e.g. in a command like
`pacman -Ss -- -pytz`. The user would be wondering why nothing seems
to be happening.

-Dan


More information about the pacman-dev mailing list