home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
c_spec
/
execute
/
echo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-02-20
|
990b
|
45 lines
#include <stdio.h>
/* ECHO.C Copy arguments to standard out. Useful
* to see what the shell will do to wild-cards and
* to print stuff from a shell script.
*
* Usage: echo arg...
* Exit status: always 0;
*
* Copyright (C) 1986, Allen I. Holub. All rights reserved.
*/
#define E(x) fprintf(stderr,"%s\n", x)
main( argc, argv )
char **argv;
{
register int suppress_cr = 0;
reargv(&argc, &argv);
if( argc > 1 && argv[1][0] == '-' )
if( !(suppress_cr = (argv[1][1] == 'n')) )
usage();
for(++argv; --argc > 0; printf("%s ", *argv++) )
;
if( !suppress_cr )
printf("\n");
exit( 0 );
}
usage()
{
E("Echo: Copyright (c) Allen I. Holub, All rights reserved\n");
E("prints its arguments to standard output. It's very useful");
E("for finding just how the shell expands arguments. Usage is:");
E("\n echo [-n] args\n");
E("If the -n is present, no newline is added to the output.");
exit( 1 );
}