tests: posix: cat(1p): added POSIX-compliant cat

This commit is contained in:
Emma Tebibyte 2024-04-27 15:16:52 -06:00
parent e278307daf
commit f022121436
Signed by untrusted user: emma
GPG Key ID: 06FA419A1698C270
4 changed files with 29 additions and 9 deletions

22
tests/posix/bin/cat Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
# SPDX-License-Identifier: FSFAP
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and this
# notice are preserved. This file is offered as-is, without any warranty.
# Strictly POSIX-compliant cat(1) implementation. See cat(1p)
for arg in "$@"; do
case "$arg" in
-u) args="$(printf '%s %s\n' "$args" "$arg")" ;;
*) args="$(printf -- '%s -i %s\n' "$args" "$arg")" ;;
esac
done
# See IEEE Std 1003.1-2017 3.282
# https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_282
IFS=' '
mm $args

View File

@ -7,7 +7,6 @@
# permitted in any medium without royalty provided the copyright notice and this # permitted in any medium without royalty provided the copyright notice and this
# notice are preserved. This file is offered as-is, without any warranty. # notice are preserved. This file is offered as-is, without any warranty.
alias true="$BIN/true" # Strictly POSIX-compliant false(1) implementation. See false(1p)
true false "$@"
true -h

View File

@ -7,7 +7,5 @@
# permitted in any medium without royalty provided the copyright notice and this # permitted in any medium without royalty provided the copyright notice and this
# notice are preserved. This file is offered as-is, without any warranty. # notice are preserved. This file is offered as-is, without any warranty.
alias false="$BIN/false" # Strictly POSIX-compliant true(1) implementation. See true(1p)
true "$@"
! false
! false -h

View File

@ -30,8 +30,9 @@ done
printf "Starting POSIX compatibility testing.\n\n" printf "Starting POSIX compatibility testing.\n\n"
for utility in tests/posix/*; do for test in tests/posix/*.sh; do
printf '%s: %s: Testing utility.\n' "$0" "$utility" export PATH="build/bin:$PATH"
printf '%s: %s: Testing utility.\n' "$0" "$test"
"$utility" "$utility"
printf '\n' printf '\n'
done done