Date: Thu, 14 Mar 96 11:30:22 EST Message-Id: <9603141630.AA18077@nyquist> From: Patrick Doyle To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: New option for "echo" utility I have added a "-s" flag to the "echo" utility included with the DJGPP distribution. This flag causes the utility to echo its arguements on separate lines. I found a need for this when I tried to use a librarian tool (for an embedded development system) that did not support a "response file" type of interface for command lines that grow too long. It does support reading its arguments from a file specified on the command line with "-i". When I tried using the standard "echo" to echo all of the commands to a file, I learned that the dain bramaged librarian tool required that its list of files be on separate lines. Anyway, I have found this to be useful, so I wonder if others might find it to be useful as well. ----<<< CUT HERE >>>--- /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include int main(int argc, char **argv) { int i; int nflag=0; FILE *out = stdout; char sep = ' '; while (argc > 1 && argv[1][0] == '-') { if ((argc > 2) && (strcmp(argv[1], "-o") == 0)) { out = fopen(argv[2], "w"); if (!out) { perror(argv[2]); out = stdout; } argc -= 2; argv += 2; } if ((argc > 2) && (strcmp(argv[1], "-a") == 0)) { out = fopen(argv[2], "a"); if (!out) { perror(argv[2]); out = stdout; } argc -= 2; argv += 2; } if ((argc > 1) && (strcmp(argv[1], "-n") == 0)) { nflag = 1; argc--; argv++; } if ((argc > 1) && (strcmp(argv[1], "-s") == 0)) { sep = '\n'; argc--; argv++; } } for (i=1; i1) fputc(sep, out); fputs(argv[i], out); } if (!nflag) fputc('\n', out); fclose(out); return 0; } ----<<< CUT HERE >>>--- -- -patrick wdoyle AT cdsp DOT neu DOT edu Happiness is a Star Trek rerun I've never seen before.