[GRASS-dev] d.save parser issue

Hi,

there seems to be a parser issue in GRASS 6 with d.save, it no longer
redirects to a file (out=... might be even more compliant with our current
user community).

It does so with this change:
--- main.c (revision 41103)
+++ main.c (working copy)
@@ -154,7 +154,7 @@
        _("Only map objects without extra header and tailer");
     only_object->answer = 0;

- if (G_parser(argc, argv))
+ if (argc > 1 && G_parser(argc, argv))
        exit(EXIT_FAILURE);

but then the GUI no longer comes up. Is there any possibility
to check if the user uses redirection - pop up GUI otherwise?

Markus

Markus Neteler wrote:

there seems to be a parser issue in GRASS 6 with d.save, it no longer
redirects to a file (out=... might be even more compliant with our current
user community).

It does so with this change:
--- main.c (revision 41103)
+++ main.c (working copy)
@@ -154,7 +154,7 @@
        _("Only map objects without extra header and tailer");
     only_object->answer = 0;

- if (G_parser(argc, argv))
+ if (argc > 1 && G_parser(argc, argv))
        exit(EXIT_FAILURE);

but then the GUI no longer comes up. Is there any possibility
to check if the user uses redirection - pop up GUI otherwise?

You can check whether stdout is a tty with isatty(1). AFAIK, you can't
portably distinguish stdout being a file from stdout being a pipe.
Also, the MSys rxvt isn't a tty according to Windows' isatty().

--
Glynn Clements <glynn@gclements.plus.com>