diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 00000000..0167345f --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything... +* +# Except the README.md and .gitignore files +!README.md +!.gitignore diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 00000000..db4bc3d7 --- /dev/null +++ b/bin/README.md @@ -0,0 +1,12 @@ +# `bin` Directory + +Apart from the README.md file (and .gitignore file), this is a +destination directory for binaries (compiled C programs, etc) and for +the 'compiled' versions of shell scripts (or any other scripting +language). +There shouldn't be any source code in here. + +The source code for the scripts is in `src/scripts`; compilation copies +the scripts (without the language-identifying suffix) to this directory. + +The directory content should be ignored except for the README.md file. diff --git a/src/makefile b/src/makefile index 771143f5..d1cfa66d 100644 --- a/src/makefile +++ b/src/makefile @@ -145,6 +145,7 @@ BUILD_DIRECTORIES = \ miscellany \ posix-regex \ primes \ + scripts \ sortfile \ sorttest \ ${SO_DIRECTORIES} \ diff --git a/src/scripts/.gitignore b/src/scripts/.gitignore new file mode 100644 index 00000000..f145fdb2 --- /dev/null +++ b/src/scripts/.gitignore @@ -0,0 +1,5 @@ +posixcmd +posixfun +posixhdr +so +wso diff --git a/src/scripts/README.md b/src/scripts/README.md new file mode 100644 index 00000000..e9074105 --- /dev/null +++ b/src/scripts/README.md @@ -0,0 +1,12 @@ +### The `scripts` Directory + +This directory contains the version-controlled source of shell scripts +(and any other scripting language). +The files here have a language-specific suffix. + +The 'compilation' process creates a copy of the script without any +suffix and moves it to the top-level `bin` directory, which can be added +to `$PATH`. +It is recommended that it is added at the end of the PATH, not the +beginning. + diff --git a/src/scripts/makefile b/src/scripts/makefile new file mode 100644 index 00000000..872f92fc --- /dev/null +++ b/src/scripts/makefile @@ -0,0 +1,26 @@ +# Makefile for miscellany directory + +include ../../etc/soq-head.mk + +BINDIR = ../../bin +CPFLAGS = -pf + +PROG01 = posixcmd +PROG02 = posixfun +PROG03 = posixhdr +PROG04 = wso +PROG05 = so + +PROGRAMS = \ + ${PROG01} \ + ${PROG02} \ + ${PROG03} \ + ${PROG04} \ + ${PROG05} \ + +all: ${PROGRAMS} + +install: all + ${CP} ${CPFLAGS} ${PROGRAMS} ${BINDIR} + +include ../../etc/soq-tail.mk diff --git a/src/scripts/posixcmd.sh b/src/scripts/posixcmd.sh new file mode 100644 index 00000000..36ad39d7 --- /dev/null +++ b/src/scripts/posixcmd.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# +# Echo URLs for POSIX commands + +baseurl="http://pubs.opengroup.org/onlinepubs/9699919799" +bq='`' + +for command in "$@" +do + echo "[$bq$command$bq]($baseurl/utilities/$command.html)" +done diff --git a/src/scripts/posixfun.sh b/src/scripts/posixfun.sh new file mode 100644 index 00000000..910bc937 --- /dev/null +++ b/src/scripts/posixfun.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# +# Echo URLs for POSIX functions + +baseurl="http://pubs.opengroup.org/onlinepubs/9699919799" +bq='`' + +for function in "$@" +do + echo "[$bq$function()$bq]($baseurl/functions/$function.html)" +done diff --git a/src/scripts/posixhdr.sh b/src/scripts/posixhdr.sh new file mode 100644 index 00000000..8d58fb11 --- /dev/null +++ b/src/scripts/posixhdr.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Echo URLs for POSIX headers + +baseurl="http://pubs.opengroup.org/onlinepubs/9699919799" +bq='`' + +for header in "$@" +do + mapped="$(echo "$header" | sed 's%/%_%; s/[<>"]//g')" + echo "[$bq<$header>$bq]($baseurl/basedefs/$mapped.html)" +done diff --git a/src/scripts/so.sh b/src/scripts/so.sh new file mode 100644 index 00000000..ef1a8403 --- /dev/null +++ b/src/scripts/so.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# +# Indent by four spaces for Stack Overflow + +exec sed '/./s/^/ /' "$@" diff --git a/src/scripts/wso.sh b/src/scripts/wso.sh new file mode 100644 index 00000000..a34e62c2 --- /dev/null +++ b/src/scripts/wso.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Print standardized 'Welcome to Stack Overflow' comment with URLs. + +cat <