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

Andrew Gregory andrew.gregory.8 at gmail.com
Sat Nov 24 15:04:30 EST 2012


On Sat, 24 Nov 2012 13:37:25 -0500
Dan McGee <dpmcgee at gmail.com> wrote:

> 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
> 

If the primary concern is user confusion, we could print a message to
stderr to the effect that we're reading from stdin.

Really though, I'm less bothered by the fact that pacman treats '-'
very differently based on context than I am that the behavior isn't
documented.  I would also be happy just tweaking the man page; perhaps
something like "Additionally, if stdin is not connected to a terminal
and a single dash (-) is passed as an argument..."


More information about the pacman-dev mailing list