GRASS Programmer's Manual
6.4.2(2012)
|
00001 #include <string.h> 00002 #include <grass/gis.h> 00003 #include <stdio.h> 00004 #include <stdlib.h> 00005 00006 /****************************************** 00007 * $GISBASE/etc/echo [-n] [-e] args 00008 * 00009 * echos its args to stdout 00010 * suppressing the newline if -n specified 00011 * prints to stderr instead if -e specified 00012 * 00013 * replaces the standard UNIX echo which 00014 * varies from machine to machine 00015 *******************************************/ 00016 00017 int main(int argc, char *argv[]) 00018 { 00019 int i; 00020 int newline; 00021 int any; 00022 FILE *stream = stdout; 00023 00024 newline = 1; 00025 any = 0; 00026 00027 for (i = 1; i < argc; i++) 00028 if (strcmp(argv[i], "-n") == 0) 00029 newline = 0; 00030 else if (strcmp(argv[i], "-e") == 0) 00031 stream = stderr; 00032 else 00033 fprintf(stream, "%s%s", any++ ? " " : "", argv[i]); 00034 if (any && newline) 00035 fprintf(stream, "\n"); 00036 00037 exit(0); 00038 }