~nabijaczleweli/voreutils

ref: 8252842e7ff74305e5642881658959dc00307d44 voreutils/tests/echo/test -rwxr-xr-x 1.3 KiB
8252842eнаб Add echo a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
# SPDX-License-Identifier: 0BSD

# GNU coreutils ship their own regexes(!), which recognise \s but don't [[:space:]]
# Conversely, regcomp(3) universally recognises [[:space:]], but not always \s (glibc does, Berkeley libcs don't)
# For ease of testing (and regeneration), pat= is set to [[:space:]] if it's \s: if retesting against GNU tac or regenerating, comment out those lines

IFS="
"

echo="${CMDDIR}echo"

"$echo" -n -n    | cmp data/-n-n    || echo "echo: -n -n     wrong" >&3
"$echo" -n a b c | cmp data/-na_b_c || echo "echo: -n a b c  wrong" >&3
"$echo" -n       | cmp data/-n      || echo "echo: -n        wrong" >&3
"$echo" -n '' '' | cmp data/-n__    || echo "echo: -n '' ''  wrong" >&3
"$echo" a b c    | cmp data/a_b_c   || echo "echo: a b c     wrong" >&3
"$echo" '' ''    | cmp data/__      || echo "echo: '' ''     wrong" >&3
"$echo"          | cmp data/blank   || echo "echo:           wrong" >&3
"$echo" ''       | cmp data/_       || echo "echo: ''        wrong" >&3

[ -w '/dev/full' ] || {
  echo "echo: skipping error testing, /dev/full unavailable" >&2
  exit 0
}

msg="$("$echo" 2>&1 > /dev/full)" && echo "echo: /dev/full okay?" >&3
[ -n "$msg" ]                     || echo "echo: no message after /dev/full?" >&3

"$echo" -n 2>&3 > /dev/full || echo "echo: /dev/full with no output wrong?" >&3