description | CLI utility for printing ranges of lines are columns |
owner | alessio.chiapperini@nullbuffer.com |
last change | Fri, 2 Dec 2022 10:47:00 +0000 (2 11:47 +0100) |
URL | git://repo.or.cz/line_util.git |
https://repo.or.cz/line_util.git | |
push URL | ssh://repo.or.cz/line_util.git |
https://repo.or.cz/line_util.git (learn more) | |
bundle info | line_util.git downloadable bundles |
content tags |
The line utility reads from standard input, printing ranges of lines and columns to standard output.
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
.LINE_MAX
bytes in length.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.
The range parameter is used to express a range of lines or columns to be printed. The lower and upper bounds of the interval must be positive integer numbers. If the lower bound is equal to the upper bound, only one line (or column) will be printed. If the upper bound is greater than the amount of lines (or columns) the output stops at the last line (or column).
The options are as follows:
Print lines between 5 and 23 from standard input until it receives an EOF (^D
) character
$ line '5,23'
Print, for each line, the characters between column 5 and 100
$ line -c "5,100"
Print only line 7
$ line '7,7'
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
(cd test && ./harness.sh)
[----------] Test environment set-up.
[==========] Running 6 test cases.
[ RUN ] should_handle_stdin
[ OK ] should_handle_stdin
[ RUN ] should_handle_singleline
[ OK ] should_handle_singleline
[ RUN ] should_handle_singlecolumn
[ OK ] should_handle_singlecolumn
[ RUN ] should_handle_multiplelines
[ OK ] should_handle_multiplelines
[ RUN ] should_handle_multiplecolumns
[ OK ] should_handle_multiplecolumns
[ RUN ] should_handle_empty_string
[ OK ] should_handle_empty_string
[==========] 6 test cases ran.
[ PASSED ] 6 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
BSD 2-Clause FreeBSD License, see LICENSE.
2022-12-02 | Alessio Chiapperini | Fix typo in README and manualmaster | commitcommitdifftreesnapshot (tar.gz zip) |
2022-12-02 | Alessio Chiapperini | Initial commit | commitcommitdifftreesnapshot (tar.gz zip) |
23 months ago | master | logtree |