Skip to content

Commit

Permalink
Add bin and src/scripts directories
Browse files Browse the repository at this point in the history
The bin directory exists as a target for build operations.
Its contents are various SO-related scripts that have semi-general use.
The source code for scripts is in the src/scripts directory.
  • Loading branch information
Jonathan Leffler committed Feb 13, 2017
1 parent 34b2031 commit 3b9e4db
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore everything...
*
# Except the README.md and .gitignore files
!README.md
!.gitignore
12 changes: 12 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ BUILD_DIRECTORIES = \
miscellany \
posix-regex \
primes \
scripts \
sortfile \
sorttest \
${SO_DIRECTORIES} \
Expand Down
5 changes: 5 additions & 0 deletions src/scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
posixcmd
posixfun
posixhdr
so
wso
12 changes: 12 additions & 0 deletions src/scripts/README.md
Original file line number Diff line number Diff line change
@@ -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.

26 changes: 26 additions & 0 deletions src/scripts/makefile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions src/scripts/posixcmd.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions src/scripts/posixfun.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions src/scripts/posixhdr.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/scripts/so.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
#
# Indent by four spaces for Stack Overflow

exec sed '/./s/^/ /' "$@"
16 changes: 16 additions & 0 deletions src/scripts/wso.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
#
# Print standardized 'Welcome to Stack Overflow' comment with URLs.

cat <<EOF
Welcome to Stack Overflow.
Please note that the preferred way of saying 'thanks' around here is by
up-voting good questions and helpful answers (once you have enough
reputation to do so), and by accepting the most helpful answer to any
question you ask (which also gives you a small boost to your
reputation).
Please see the [About] page and also [How do I ask questions
here?](http://stackoverflow.com/help/how-to-ask) and
[What do I do when someone answers my
question?](http://stackoverflow.com/help/someone-answers)
EOF

0 comments on commit 3b9e4db

Please sign in to comment.