Initial version.
This commit is contained in:
3
auto/echo/Makefile
Normal file
3
auto/echo/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
echo.exe: echo.c
|
||||
mingw32-gcc -o echo.exe -O2 echo.c
|
||||
26
auto/echo/build
Normal file
26
auto/echo/build
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
# Copyright (C) Igor Sysoev
|
||||
# Copyright (C) NGINX, Inc.
|
||||
|
||||
|
||||
$echo 'building an "echo" program'
|
||||
|
||||
rm -f $NXT_BUILD_DIR/echo
|
||||
|
||||
nxt_echo_test="$CC -o $NXT_BUILD_DIR/echo -O $NXT_CC_OPT
|
||||
auto/echo/echo.c $NXT_LD_OPT"
|
||||
|
||||
nxt_echo_err=`$nxt_echo_test 2>&1`
|
||||
|
||||
if [ ! -x $NXT_BUILD_DIR/echo ]; then
|
||||
$echo
|
||||
$echo $0: error: cannot build an \"echo\" program:
|
||||
$echo
|
||||
$echo $nxt_echo_test
|
||||
$echo
|
||||
$echo $nxt_echo_err
|
||||
$echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo=$NXT_BUILD_DIR/echo
|
||||
43
auto/echo/echo.c
Normal file
43
auto/echo/echo.c
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) Igor Sysoev
|
||||
* Copyright (C) NGINX, Inc.
|
||||
*
|
||||
* A portable "echo" program that supports "-n" option:
|
||||
* echo Hello world!
|
||||
* echo "Hello world!"
|
||||
* echo -n Hello world!
|
||||
* echo
|
||||
*
|
||||
* It also passes "\c" characters as is.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *const *argv)
|
||||
{
|
||||
int i = 1;
|
||||
int nl = 1;
|
||||
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "-n") == 0) {
|
||||
nl = 0;
|
||||
i++;
|
||||
}
|
||||
|
||||
while (i < argc) {
|
||||
printf("%s%s", argv[i], (i == argc - 1) ? "" : " ");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nl) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user