4 Commits

3 changed files with 27 additions and 23 deletions

View File

@@ -114,7 +114,7 @@ build/bin/false: src/false.c build
.PHONY: fileis
fileis: build/bin/fileis
build/bin/fileis: src/fileis.rs build
build/bin/fileis: src/fileis.rs build rustlibs
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ src/fileis.rs
.PHONY: fop

View File

@@ -8,20 +8,20 @@
.PRAGMA: command_comment
.PHONY: scrut_tests
scrut_tests: scrut_help scrut_options
.PHONY: fileis_tests
fileis_tests: fileis_help fileis_options
.PHONY: scrut_help
scrut_help: $(BIN)/scrut
! $(BIN)/scrut -h
.PHONY: fileis_help
fileis_help: $(BIN)/fileis
! $(BIN)/fileis -h
.PHONY: scrut_options
# scrut tests file attributes, but files of a certain attribute aren't
.PHONY: fileis_options
# fileis tests file attributes, but files of a certain attribute aren't
# guaranteed to be present on a system. This test checks all of the files in
# harakit and, if test(1p) says a file matches a certain attribute, then checks
# scrut.
# fileis.
# opts are space-delimited (for command splitting), sel is not
scrut_options: $(BIN)/scrut
fileis_options: $(BIN)/fileis
set -e; \
opts="b c d e f g k p r s u w x L S"; \
sel=; \
@@ -30,12 +30,12 @@ scrut_options: $(BIN)/scrut
for opt in $$opts; \
do if ! printf "%s\n" $$sel | grep $$opt >/dev/null; then \
if test -$$opt "$$f"; then \
if ! $(BIN)/scrut -$$opt "$$f"; \
then printf "[!!] scrut -%s failed on %s.\n" \
if ! $(BIN)/fileis -$$opt "$$f"; \
then printf "[!!] fileis -%s failed on %s.\n" \
$$opt "$$f"; \
fi; \
sel="$$sel$$opt"; \
printf "[OK] Tested scrut -%s using %s\n" \
printf "[OK] Tested fileis -%s using %s\n" \
$$opt "$$f"; \
fi; \
fi; \

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# Copyright (c) 2024 DTB <trinity@trinity.moe>
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
# Copyright (c) 20242025 Emma Tebibyte <emma@tebibyte.media>
# SPDX-License-Identifier: FSFAP
#
# Copying and distribution of this file, with or without modification, are
@@ -26,7 +26,7 @@ npc_args:
.PHONY: npc_ascii
# Test 0x00 to 0x7f in input; in other words, the full 7b ASCII range.
npc_ascii: npc_ascii_controls npc_ascii_symbols npc_ascii_uppers # \
npc_ascii: npc_ascii_controls npc_ascii_uppers # npc_ascii_symbols \
# npc_ascii_lowers
.PHONY: npc_ascii_controls
@@ -63,14 +63,18 @@ npc_ascii_controls:
| tail -n 1 \
| xargs -I out test "^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_"
.PHONY: npc_ascii_symbols
# ASCII 0x1f to 0x3f (^_ and symbols)
npc_ascii_symbols:
# shell quoting olympics
awk 'BEGIN{ for (i = 31; i < 64; ++i) printf("%c", i); print }' \
| $(BIN)/npc \
| sed -e s"/\'/\\\'/g" -e 's/"/\\"/g' \
| xargs -I out test "^_ !\"#$$%&'()*+,-./0123456789:;<=>?" = out
# This test is broken on Linux and will need closer inspection along with GNU
# xargs(1).
# .PHONY: npc_ascii_symbols
# # ASCII 0x1f to 0x3f (^_ and symbols)
# npc_ascii_symbols:
# # shell quoting olympics
# c="$(awk 'BEGIN{ for (i = 31; i < 64; ++i) printf("%c", i); print }')"
#
# printf '%s\n' "$c" | $(BIN)/npc \
# | sed -e s"/\'/\\\'/g" -e 's/"/\\"/g' \
# | tr -d '\n' \
# | xargs -I out test "^_ !\"#$$%&\'()*+,-./0123456789:;<=>?" = out
.PHONY: npc_ascii_uppers
# ASCII 0x40 to 0x5f (uppercases)