1
0

independ echo

This commit is contained in:
dtb
2022-09-16 10:56:10 -04:00
parent 980b4bae35
commit bf073593c8
4 changed files with 35 additions and 5 deletions

28
echo/Makefile Normal file
View File

@@ -0,0 +1,28 @@
all: echo
clean:
rm -rf ../dist/echo ../dist/echo.tar ../dist/echo.tar.gz echo
dist: ../dist/echo.tar.gz
sane: echo.c ../include/sysexits.h
$(CC) -DDONT_USE_SYSTEM_SYSEXITS -o echo echo.c
echo: echo.c
$(CC) -o echo echo.c
../dist/echo: echo
mkdir -p ../dist/echo.tmp/bin/ ../dist/echo.tmp/share/man/man1/
cp echo ../dist/echo.tmp/bin/echo
cp echo.1 ../dist/echo.tmp/share/man/man1/echo.1
mv ../dist/echo.tmp ../dist/echo
../dist/echo.tar: ../dist/echo
cd ../dist/echo && pax -w -x ustar . >../echo.tar.tmp
mv ../dist/echo.tar.tmp ../dist/echo.tar
../dist/echo.tar.gz: ../dist/echo.tar
gzip -c <../dist/echo.tar >../dist/echo.tar.gz.tmp
mv ../dist/echo.tar.gz.tmp ../dist/echo.tar.gz
.PHONY: all clean sane

27
echo/echo.1 Normal file
View File

@@ -0,0 +1,27 @@
.TH ECHO 1
.SH NAME
echo \(en echo arguments
.SH SYNOPSIS
echo
.RB [ argument... ]
.SH DESCRIPTION
Echo echoes given arguments delimited by an ASCII blank, with a terminating newline.
.SH BUGS
Echo should not be used in scripts; printf(1) should be used in its place.
.SH STANDARDS
Echo does not recognize the escape sequences described in the X/Open System Interface Extension to POSIX.
This is intended.
.SH COPYRIGHT
Public domain.

19
echo/echo.c Normal file
View File

@@ -0,0 +1,19 @@
#include <sysexits.h>
#include <stddef.h> /* NULL */
#include <unistd.h> /* write(2) */
#include "libio.h" /* fdprint(3) */
int main(int argc, char **argv){
if(*argv == NULL)
return EX_OSERR;
while(*++argv != NULL){
fdprint(1, *argv);
if(*(argv+1) != NULL)
write(1, " ", 1);
}
write(1, "\n", 1);
return EX_OK;
}