description | The pp (prepend) utility takes the content of the file named by the source operand and inserts or prepends it above the first line of the file named by the target operand. |
owner | alessio.chiapperini@nullbuffer.com |
last change | Tue, 28 May 2024 10:05:43 +0000 (28 12:05 +0200) |
URL | git://repo.or.cz/pp.git |
https://repo.or.cz/pp.git | |
push URL | ssh://repo.or.cz/pp.git |
https://repo.or.cz/pp.git (learn more) | |
bundle info | pp.git downloadable bundles |
content tags |
The pp (prepend) utility takes the content of the file named by the source operand and inserts or prepends it above the first line of the file named by the target operand. The file operands are processed in command-line order. If the source file is a single dash (‘-’) or absent, pp reads from the standard input.
So, essentially, if I have a CSV file without a header and I want to quickly insert the header from a file, I would run:
$ pp header.txt spreadsheet.csv
and it would be functionally equivalent to
$ cat header.txt spreadsheet.csv > temp
$ mv temp spreadsheet.csv
scan-build
using checkers alpha.security
, alpha.core.CastSize
,
alpha.core.CastToStruct
, alpha.core.IdenticalExpr
, alpha.core.PointerArithm
, alpha.core.PointerSub
,
alpha.core.SizeofPtr
, alpha.core.TestAfterDivZero
, alpha.unix
The only dependency is a toolchain supporting the following flags:
CFLAGS = -std=c99 -O2 -Wall -Wextra -Wpedantic \
-Walloca -Wcast-qual -Wconversion -Wformat=2 -Wformat-security \
-Wnull-dereference -Wstack-protector -Wvla -Warray-bounds \
-Wbad-function-cast -Wconversion -Wshadow -Wstrict-overflow=4 -Wundef \
-Wstrict-prototypes -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough \
-Wpointer-arith -Wswitch-enum \
-D_FORTIFY_SOURCE=2 \
-fstack-protector-strong -fPIE -fstack-clash-protection
LDFLAGS = -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,separate-code
Otherwise you can just remove the security flags and compile it with
CFLAGS = -std=c99 -O2 -Wall -Wextra -Wpedantic
LDFLAGS =
or pass your own flags to make
make CC=gcc CFLAGS=... LDFLAGS=...
Clone this repository then
$ make PREFIX=/usr install
This will install the compiled binary under PREFIX
(/usr/bin
) in this case, if not specified PREFIX
will default
to /usr/local
. For staged installs, DESTDIR
is also supported. As the binary does not have any dependency it does
not have to be installed before use.
Using pp is quite simple, you just specify the source file and target file
$ pp source target
The source file however, can be omitted, in this case the program takes the input from the standard input until EOF
or
^D
is reached
$ pp target
this behavior can also be achieved by using ‘-’ as source file
$ pp - target
In order to build on any Unix-like system, simply run make
. Since the binary does not have any dependencies, it can
just be copied into your PATH
.
The test suite consists of a POSIX shell script called harness.sh
contained in the test
folder. It's output is
similar to googletest's and it can be invoked with make test
which, if
everything is working should output something similar to
./test/harness.sh
[----------] Test environment set-up.
[==========] Running 7 test cases.
[ RUN ] empty_source
[ OK ] empty_source
[ RUN ] empty_destination
[ OK ] empty_destination
[ RUN ] trivial_test
[ OK ] trivial_test
[ RUN ] stdin_source
[ OK ] stdin_source
[ RUN ] utf8_source
[ OK ] utf8_source
[ RUN ] filename_dash
[ OK ] filename_dash
[ RUN ] opt_source
[ OK ] opt_source
[==========] 7 test cases ran.
[ PASSED ] 7 tests.
[ FAILED ] 0 tests.
[----------] Test environment teardown.
Static analysis on the code base is done by using clang's static analyzer run through scan-build.sh
which wraps the
scan-build
utility. The checkers used are part of the
Experimental Checkers
(aka alpha checkers):
alpha.security
alpha.core.CastSize
alpha.core.CastToStruct
alpha.core.IdenticalExpr
alpha.core.PointerArithm
alpha.core.PointerSub
alpha.core.SizeofPtr
alpha.core.TestAfterDivZero
alpha.unix
Send patches on the mailing list, report bugs on the issue tracker.
BSD 2-Clause FreeBSD License, see LICENSE.
4 months ago | master | logtree |