On Sat, 24 Nov 2012 13:37:25 -0500 Dan McGee <[email protected]> wrote:
> On Sat, Nov 24, 2012 at 1:29 PM, Dave Reisner <[email protected]> > 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 <[email protected]> > >> --- > >> 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..."
