bp

NAME

bp - boilerplate generator

SYNOPSIS

bp [-d dirname] boilerplate-name
bp [-x | [-d dirname] -X]

DESCRIPTION

The bp(1) utility writes a boilerplate to standard output as specified by the boilerplate-name operand.

OPTIONS

-d dirname
Search for boilerplates stored in directory dirname, rather than in $HOME/bpdir.
-X
List boilerplates found in the boilerplate directory.
-x
Output an explanation message.

By default, the bp(1) utility searches for boilerplates in $HOME/bpdir. If the environment variable BPDIR is set to a directory name, this overrides the default. The -d option takes precedence if it is on the command line. The value for BPDIR must end with a trailing slash character (but an argument to -d need not).

BOILERPLATES

Boilerplates can be very effective for improving consistency across similar types of files, improving productivity when working with known templates, and reducing retyping errors. A set of simple macros can be included in the boilerplates to personalize the output (see Macros).

Boilerplates all start with a line that describes the boilerplate, and is not output as part of the writing to standard output. This line begins with the four characters #BP\t, where \t represents a tab. (This can be used in a magic file to identify boilerplates.) Everything else on the line is a simple, one-line description of the boilerplate contents that is written to standard output when the -X flag is used.

Boilerplates can be used for anything, including simple look-up files for information (such as postal codes, the table of elements, macro names, office phone extensions). A sample of the boilerplates used in the development environment include the following:

DEBUG DEBUG macro definition
SSI List of local feature test macros.
api.c Simple function in C (with a test-program framework).
cleanup Clean-up Checklist for development work in a directory
codeids Copyright and RCSid character strings.
header.h Basic header file with guards and copyright notice.
makefile Simple makefile template with standard targets.
makefile.lib Makefile for library with simple targets.
makefile.pub Makefile for a publications directory.
modcopyr.c Standard corporate copyright for ported source.
modcopyr.mm Standard corporate copyright for translated man page.
newcopyr.c Standard corporate copyright for new C source.
newcopyr.sh Standard corporate copyright for new shell or make source.
setvbuf Unbuffer calls for stdout and stderr.
sutil.c Simple utility template for filter program.
testdata Text file to be used as test data.
util.c Simple utility template.
util.man Template man page file (troff man macros).
util.sh Shell script template w. options, help, and copyright

If boilerplates are broken out into types across different directories, bp(1) with a specific directory name can be aliased to a more appropriate command name.

$ alias lookup="bp -d /dev/fs/X/info"
$ lookup -X
/dev/fs/X/info
Elements			Table of Elements
ZipCodes			Area zip codes
Suppliers		 List of contact numbers

Macros

A macro is a string which bp(1) replaces with some value from the user's environment. Macros begin with the @ character; most macros are only two characters long. The macros deal with time, the user's name, environment variables, and shell script output:
Meaning Macro Example
An @ symbol @@ @
Weekday name @A Tuesday
Weekday name (abbr) @a Tue
Month @B December
Month (abbr) @b Dec
Century @C 19
Date & time @c 12/30/97 15:24:14
Date (numeric) @D 12/30/97
Day (decimal) @d 30
Month (decimal) @m 12
Hour (24-hour) @H 15
Hour (12-hour) @I 03
AM/PM @p PM
Time (24-hour) @R 15:24
Full year @Y 1997
Abbrev. year @y 97
User name, no domain @U dana
Ushering with domain @u ACCTNG+dana
Environment variable @(VAR)
Command output @{command}

A meaningless macro (for example, one that names a non-existent environment variable or uses an unused letter such as Q) is output without change.

DIAGNOSTICS

The bp(1) utility exits 0 on success, and >0 if an error occurs.

EXAMPLE

The following simple boilerplate presents a simple shell script:
#BP  Shell script template
#
# Utility name: name
#
# Created by: @U on @c
# Copyright @Y Your Company Name
#
CMD=$(basename $0)
USAGE="usage: $CMD [-f arg] ..."
while getopts f: opt
do
	 case "$opt" in
	 'f') echo "Option: " $OPTARG
		;;
	 '?') echo $USAGE
		exit 1;;
	 esac
done
shift $OPTIND-1
for arg in $@
do
	 echo $arg
done