tests: posix: cat(1p): added POSIX-compliant cat
This commit is contained in:
parent
e278307daf
commit
f022121436
22
tests/posix/bin/cat
Executable file
22
tests/posix/bin/cat
Executable 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
|
@ -7,7 +7,6 @@
|
||||
# permitted in any medium without royalty provided the copyright notice and this
|
||||
# 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
|
||||
true -h
|
||||
false "$@"
|
@ -7,7 +7,5 @@
|
||||
# permitted in any medium without royalty provided the copyright notice and this
|
||||
# notice are preserved. This file is offered as-is, without any warranty.
|
||||
|
||||
alias false="$BIN/false"
|
||||
|
||||
! false
|
||||
! false -h
|
||||
# Strictly POSIX-compliant true(1) implementation. See true(1p)
|
||||
true "$@"
|
@ -30,8 +30,9 @@ done
|
||||
|
||||
printf "Starting POSIX compatibility testing.\n\n"
|
||||
|
||||
for utility in tests/posix/*; do
|
||||
printf '%s: %s: Testing utility.\n' "$0" "$utility"
|
||||
for test in tests/posix/*.sh; do
|
||||
export PATH="build/bin:$PATH"
|
||||
printf '%s: %s: Testing utility.\n' "$0" "$test"
|
||||
"$utility"
|
||||
printf '\n'
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user