diff --git a/homepage/software/index.m4 b/homepage/software/index.m4 index f3779a1..c6c0ba4 100644 --- a/homepage/software/index.m4 +++ b/homepage/software/index.m4 @@ -4,6 +4,7 @@ define(`_TITLE', `guide to software')dnl define(`_DESCRIPTION', `do not read')dnl define(`_PAGE', `software/')dnl define(`_STYLE', `')dnl +define(`_nothing', `')dnl include(`../html.m4')dnl include(`../head.m4')dnl @@ -38,6 +39,71 @@ Plan 9 from Bell Labs, due to its historical relationship with UNIX, will be men
  • _hyperlink(`https://github.com/dspinellis/unix-history-repo', `unix-history-repo') (GitHub)
  • +

    POSIX

    + +

    echo(1)

    + +

    +Don't use _code(`echo(1)'), use _code(`printf(1)'). +_code(`printf(1)') simulates the _code(`printf(3)') function in the C standard I/O library which has no significant variations, whereas the functionality of _code(`echo(1)') can vary between vendors. +

    +

    +_code(`printf "%s" "$*"') does not work as _code(`echo(1)') though it's been said to do so (including by this page). +

    +

    +The following is an implementation of _code(`echo(1)') in the C programming language, using the standard library. +

    +
    +#include <stdio.h>
    +int main(int argc, char *argv[]) {
    +	int i;
    +	for(i = 1; ; ) {
    +		printf("%s", argv[i]);
    +		++i;
    +		if(i == argc) {
    +			putchar('\n');
    +			break;
    +		} else
    +			putchar(' ');
    +	}
    +	return 0;
    +}
    +
    +

    +The following is an implementation of _code(`echo(1)') in shell. +

    +
    +while :; do
    +	printf "%s" "$1"
    +	`shift'
    +	if test -z "$1"; then
    +		printf "\n"
    +		break
    +	else
    +		printf " "
    +	fi
    +done
    +
    + +

    find(1)

    + + +

    ed(1)

    + +

    +A particularly shoddy attempt at _code(`ed(1)') is provided by _code(`busybox'). +A traditional _code(`ed(1)') implementation is in plan9ports. +I'm pretty sure some later UNIX-based OSes doubled the _code(`ed(1)') buffers, there's pretty much no downside to doing so in the modern era but it should be very easy to do yourself if it hasn't already been done (just double some of the array sizes in the beginning of _code(`ed.c')). +

    +

    Advanced Configuration and Power Interface