GRASS GIS 8 Programmer's Manual 8.3.2(2024)-exported
Loading...
Searching...
No Matches
echo.c
Go to the documentation of this file.
1#include <string.h>
2#include <grass/gis.h>
3#include <stdio.h>
4#include <stdlib.h>
5
6/******************************************
7 * $GISBASE/etc/echo [-n] [-e] args
8 *
9 * echos its args to stdout
10 * suppressing the newline if -n specified
11 * prints to stderr instead if -e specified
12 *
13 * replaces the standard UNIX echo which
14 * varies from machine to machine
15 *******************************************/
16
17int main(int argc, char *argv[])
18{
19 int i;
20 int newline;
21 int any;
22 FILE *stream = stdout;
23
24 newline = 1;
25 any = 0;
26
27 for (i = 1; i < argc; i++)
28 if (strcmp(argv[i], "-n") == 0)
29 newline = 0;
30 else if (strcmp(argv[i], "-e") == 0)
31 stream = stderr;
32 else
33 fprintf(stream, "%s%s", any++ ? " " : "", argv[i]);
34 if (any && newline)
35 fprintf(stream, "\n");
36
37 exit(0);
38}
int main(void)
Definition winlocale.c:201