Results for builtin-printf.test.sh

statusoshosh-cpp
pass 4848
ok 88
N-I 66
FAIL 11
total6363
caseoshosh-cppdescription
0pass pass printf with no args
1pass pass printf -v %s
2pass pass printf -v %q
3pass pass printf -v a[1]
4pass pass printf -v syntax error
5pass pass dynamic declare instead of %s
6ok ok dynamic declare instead of %q
detailsdetails
7ok ok printf -v dynamic scope
detailsdetails
8pass pass printf with too few arguments
9pass pass printf with too many arguments
10pass pass printf width strings
11pass pass printf integer
12pass pass printf %6.4d -- "precision" does padding for integers
13pass pass printf %6.4x X o
14pass pass %06d zero padding vs. %6.6d
15pass pass %06x %06X %06o
16pass pass %06s is no-op
17pass pass printf %6.4s does both truncation and padding
18pass pass printf %6.0s and %0.0s
19pass pass printf %6.s and %0.s
20pass pass printf %*.*s (width/precision from args)
21pass pass unsigned / octal / hex
22pass pass unsigned / octal / hex big
23ok ok empty string (osh is more strict)
detailsdetails
24pass pass No char after ' => zero code point
25pass pass Unicode char with '
26pass pass Invalid UTF-8
27ok ok Too large
detailsdetails
28N-I N-I negative numbers with unsigned / octal / hex
detailsdetails
29N-I N-I printf floating point (not required, but they all implement it)
detailsdetails
30N-I N-I printf floating point with - and 0
detailsdetails
31N-I N-I printf eE fF gG
detailsdetails
32pass pass printf backslash escapes
33pass pass printf octal backslash escapes
34pass pass printf unicode backslash escapes
35pass pass printf invalid backslash escape (is ignored)
36pass pass printf % escapes
37pass pass printf %c ASCII
38pass pass printf %c unicode - prints the first BYTE of a string - it does not respect UTF-8
39ok ok printf invalid format
detailsdetails
40pass pass printf %q
41pass pass printf %6q (width)
42FAIL FAIL printf negative numbers
detailsdetails
43N-I N-I printf + and space flags
detailsdetails
44N-I N-I printf # flag
detailsdetails
45ok ok Runtime error for invalid integer
detailsdetails
46pass pass %(strftime format)T
47pass pass %(strftime format)T doesn't respect TZ if not exported
48pass pass %(strftime format)T TZ in environ but not in shell's memory
49pass pass %10.5(strftime format)T
50pass pass Regression for 'printf x y'
51ok ok bash truncates long strftime string at 128
detailsdetails
52pass pass printf positive integer overflow
53pass pass printf negative integer overflow
54pass pass printf %b does backslash escaping
55pass pass printf %b unicode escapes
56pass pass printf %b respects \c early return
57pass pass printf %b supports octal escapes, both \141 and \0141
58pass pass printf %b with truncated octal escapes
59pass pass printf %d %X support hex 0x5 and octal 055
60pass pass printf %d with + prefix (positive sign)
61ok ok leading spaces are accepted in value given to %d %X, but not trailing spaces
detailsdetails
62pass pass Arbitrary base 64#a is rejected (unlike in shell arithmetic)
96 passed, 16 OK, 12 not implemented, 0 BUG, 1 failed, 0 timeouts, 0 cases skipped
1 failed under osh

Details on runs that didn't PASS

osh6 dynamic declare instead of %q

stdout:
$'"quoted" with spaces and \\'
stderr:
osh-cpp6 dynamic declare instead of %q

stdout:
$'"quoted" with spaces and \\'
stderr:
osh7 printf -v dynamic scope

stdout:
dollar=dollar
--
dollar='$'
mylocal=mylocal
--
dollar='$'
mylocal=
stderr:
osh-cpp7 printf -v dynamic scope

stdout:
dollar=dollar
--
dollar='$'
mylocal=mylocal
--
dollar='$'
mylocal=
stderr:
osh23 empty string (osh is more strict)

stdout:
stderr: 
  printf '%d\n' ''
                ^
[ stdin ]:1: printf expected an integer, got ''
osh-cpp23 empty string (osh is more strict)

stdout:
stderr: 
  printf '%d\n' ''
                ^
[ stdin ]:1: printf expected an integer, got ''
osh27 Too large

stdout:
too large
f4
244
364

stderr:
  printf '%x\n' \'$too_large
                ^~
[ stdin ]:5: Warning: UTF-8 decode: Integer too large at offset 1 in string of 5 bytes
  printf '%u\n' \'$too_large
                ^~
[ stdin ]:6: Warning: UTF-8 decode: Integer too large at offset 1 in string of 5 bytes
  printf '%o\n' \'$too_large
                ^~
[ stdin ]:7: Warning: UTF-8 decode: Integer too large at offset 1 in string of 5 bytes
osh-cpp27 Too large

stdout:
too large
f4
244
364

stderr:
  printf '%x\n' \'$too_large
                ^~
[ stdin ]:5: Warning: UTF-8 decode: Integer too large at offset 1 in string of 5 bytes
  printf '%u\n' \'$too_large
                ^~
[ stdin ]:6: Warning: UTF-8 decode: Integer too large at offset 1 in string of 5 bytes
  printf '%o\n' \'$too_large
                ^~
[ stdin ]:7: Warning: UTF-8 decode: Integer too large at offset 1 in string of 5 bytes
osh28 negative numbers with unsigned / octal / hex

stdout:
status=1
status=1
status=1
status=1
stderr:
  [%u]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%u]\n' -42
         ^
[ stdin ]:1: Can't format negative number with %u: -42
  [%o]\n
    ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[%o]\n' -42
         ^
[ stdin ]:4: Can't format negative number with %o: -42
  [%x]\n
    ^
[ printf arg at line 7 of [ stdin ] ]:1

  printf '[%x]\n' -42
         ^
[ stdin ]:7: Can't format negative number with %x: -42
  [%X]\n
    ^
[ printf arg at line 10 of [ stdin ] ]:1

  printf '[%X]\n' -42
         ^
[ stdin ]:10: Can't format negative number with %X: -42
osh-cpp28 negative numbers with unsigned / octal / hex

stdout:
status=1
status=1
status=1
status=1
stderr:
  [%u]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%u]\n' -42
         ^
[ stdin ]:1: Can't format negative number with %u: -42
  [%o]\n
    ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[%o]\n' -42
         ^
[ stdin ]:4: Can't format negative number with %o: -42
  [%x]\n
    ^
[ printf arg at line 7 of [ stdin ] ]:1

  printf '[%x]\n' -42
         ^
[ stdin ]:7: Can't format negative number with %x: -42
  [%X]\n
    ^
[ printf arg at line 10 of [ stdin ] ]:1

  printf '[%X]\n' -42
         ^
[ stdin ]:10: Can't format negative number with %X: -42
osh29 printf floating point (not required, but they all implement it)

stdout:
stderr: 
  [%f]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%f]\n' 3.14159
         ^
[ stdin ]:1: osh printf doesn't support floating point
  [%.2f]\n
      ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%.2f]\n' 3.14159
         ^
[ stdin ]:2: osh printf doesn't support floating point
  [%8.2f]\n
       ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[%8.2f]\n' 3.14159
         ^
[ stdin ]:3: osh printf doesn't support floating point
  [%-8.2f]\n
        ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[%-8.2f]\n' 3.14159
         ^
[ stdin ]:4: osh printf doesn't support floating point
  [%-f]\n
     ^
[ printf arg at line 5 of [ stdin ] ]:1

  printf '[%-f]\n' 3.14159
         ^
[ stdin ]:5: osh printf doesn't support floating point
  [%-f]\n
     ^
[ printf arg at line 6 of [ stdin ] ]:1

  printf '[%-f]\n' 3.14
         ^
[ stdin ]:6: osh printf doesn't support floating point
osh-cpp29 printf floating point (not required, but they all implement it)

stdout:
stderr: 
  [%f]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%f]\n' 3.14159
         ^
[ stdin ]:1: osh printf doesn't support floating point
  [%.2f]\n
      ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%.2f]\n' 3.14159
         ^
[ stdin ]:2: osh printf doesn't support floating point
  [%8.2f]\n
       ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[%8.2f]\n' 3.14159
         ^
[ stdin ]:3: osh printf doesn't support floating point
  [%-8.2f]\n
        ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[%-8.2f]\n' 3.14159
         ^
[ stdin ]:4: osh printf doesn't support floating point
  [%-f]\n
     ^
[ printf arg at line 5 of [ stdin ] ]:1

  printf '[%-f]\n' 3.14159
         ^
[ stdin ]:5: osh printf doesn't support floating point
  [%-f]\n
     ^
[ printf arg at line 6 of [ stdin ] ]:1

  printf '[%-f]\n' 3.14
         ^
[ stdin ]:6: osh printf doesn't support floating point
osh30 printf floating point with - and 0

stdout:
---
stderr:
  [%8.4f]\n
       ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%8.4f]\n' 3.14
         ^
[ stdin ]:1: osh printf doesn't support floating point
  [%08.4f]\n
        ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%08.4f]\n' 3.14
         ^
[ stdin ]:2: osh printf doesn't support floating point
  [%8.04f]\n
       ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[%8.04f]\n' 3.14  # meaning less 0
         ^
[ stdin ]:3: Expected a printf format character
  [%08.04f]\n
        ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[%08.04f]\n' 3.14
         ^
[ stdin ]:4: Expected a printf format character
  [%-8.4f]\n
        ^
[ printf arg at line 6 of [ stdin ] ]:1

  printf '[%-8.4f]\n' 3.14
         ^
[ stdin ]:6: osh printf doesn't support floating point
  [%-08.4f]\n
         ^
[ printf arg at line 7 of [ stdin ] ]:1

  printf '[%-08.4f]\n' 3.14
         ^
[ stdin ]:7: osh printf doesn't support floating point
  [%-8.04f]\n
        ^
[ printf arg at line 8 of [ stdin ] ]:1

  printf '[%-8.04f]\n' 3.14
         ^
[ stdin ]:8: Expected a printf format character
  [%-08.04f]\n
         ^
[ printf arg at line 9 of [ stdin ] ]:1

  printf '[%-08.04f]\n' 3.14
         ^
[ stdin ]:9: Expected a printf format character
osh-cpp30 printf floating point with - and 0

stdout:
---
stderr:
  [%8.4f]\n
       ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%8.4f]\n' 3.14
         ^
[ stdin ]:1: osh printf doesn't support floating point
  [%08.4f]\n
        ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%08.4f]\n' 3.14
         ^
[ stdin ]:2: osh printf doesn't support floating point
  [%8.04f]\n
       ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[%8.04f]\n' 3.14  # meaning less 0
         ^
[ stdin ]:3: Expected a printf format character
  [%08.04f]\n
        ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[%08.04f]\n' 3.14
         ^
[ stdin ]:4: Expected a printf format character
  [%-8.4f]\n
        ^
[ printf arg at line 6 of [ stdin ] ]:1

  printf '[%-8.4f]\n' 3.14
         ^
[ stdin ]:6: osh printf doesn't support floating point
  [%-08.4f]\n
         ^
[ printf arg at line 7 of [ stdin ] ]:1

  printf '[%-08.4f]\n' 3.14
         ^
[ stdin ]:7: osh printf doesn't support floating point
  [%-8.04f]\n
        ^
[ printf arg at line 8 of [ stdin ] ]:1

  printf '[%-8.04f]\n' 3.14
         ^
[ stdin ]:8: Expected a printf format character
  [%-08.04f]\n
         ^
[ printf arg at line 9 of [ stdin ] ]:1

  printf '[%-08.04f]\n' 3.14
         ^
[ stdin ]:9: Expected a printf format character
osh31 printf eE fF gG

stdout:
stderr: 
  [%e]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%e]\n' 3.14
         ^
[ stdin ]:1: osh printf doesn't support floating point
  [%E]\n
    ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%E]\n' 3.14
         ^
[ stdin ]:2: osh printf doesn't support floating point
  [%f]\n
    ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[%f]\n' 3.14
         ^
[ stdin ]:3: osh printf doesn't support floating point
  [%g]\n
    ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[%g]\n' 3.14
         ^
[ stdin ]:4: osh printf doesn't support floating point
  [%G]\n
    ^
[ printf arg at line 5 of [ stdin ] ]:1

  printf '[%G]\n' 3.14
         ^
[ stdin ]:5: osh printf doesn't support floating point
osh-cpp31 printf eE fF gG

stdout:
stderr: 
  [%e]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%e]\n' 3.14
         ^
[ stdin ]:1: osh printf doesn't support floating point
  [%E]\n
    ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%E]\n' 3.14
         ^
[ stdin ]:2: osh printf doesn't support floating point
  [%f]\n
    ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[%f]\n' 3.14
         ^
[ stdin ]:3: osh printf doesn't support floating point
  [%g]\n
    ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[%g]\n' 3.14
         ^
[ stdin ]:4: osh printf doesn't support floating point
  [%G]\n
    ^
[ printf arg at line 5 of [ stdin ] ]:1

  printf '[%G]\n' 3.14
         ^
[ stdin ]:5: osh printf doesn't support floating point
osh39 printf invalid format

stdout:
status=2
status=2
stderr:
  %z
   ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '%z' 42
         ^
[ stdin ]:1: Invalid printf format character
  %-z
    ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '%-z' 42
         ^
[ stdin ]:3: Invalid printf format character
osh-cpp39 printf invalid format

stdout:
status=2
status=2
stderr:
  %z
   ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '%z' 42
         ^
[ stdin ]:1: Invalid printf format character
  %-z
    ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '%-z' 42
         ^
[ stdin ]:3: Invalid printf format character
osh42 printf negative numbers

[osh stdout] Expected '[-42] status=0\n[-42] status=0\n[-42] status=0\n[-42] status=0\n[-42] status=0\n[-42] status=0\nstatus=1\nstatus=1\n' Got '[-42] status=0\n[-42] status=0\n[-42] status=0\n[-42] status=0\nstatus=1\nstatus=1\nstatus=1\nstatus=1\n'

stdout:
[-42] status=0
[-42] status=0
[-42] status=0
[-42] status=0
status=1
status=1
status=1
status=1
stderr:
  printf '[%d] ' ' -42 '
                 ^
[ stdin ]:11: printf expected an integer, got ' -42 '
  printf '[%i] ' ' -42 '
                 ^
[ stdin ]:13: printf expected an integer, got ' -42 '
  printf '[%d] ' ' -42z'
                 ^
[ stdin ]:16: printf expected an integer, got ' -42z'
  printf '[%i] ' ' -42z'
                 ^
[ stdin ]:18: printf expected an integer, got ' -42z'
osh-cpp42 printf negative numbers

[osh-cpp stdout] Expected '[-42] status=0\n[-42] status=0\n[-42] status=0\n[-42] status=0\n[-42] status=0\n[-42] status=0\nstatus=1\nstatus=1\n' Got '[-42] status=0\n[-42] status=0\n[-42] status=0\n[-42] status=0\nstatus=1\nstatus=1\nstatus=1\nstatus=1\n'

stdout:
[-42] status=0
[-42] status=0
[-42] status=0
[-42] status=0
status=1
status=1
status=1
status=1
stderr:
  printf '[%d] ' ' -42 '
                 ^
[ stdin ]:11: printf expected an integer, got ' -42 '
  printf '[%i] ' ' -42 '
                 ^
[ stdin ]:13: printf expected an integer, got ' -42 '
  printf '[%d] ' ' -42z'
                 ^
[ stdin ]:16: printf expected an integer, got ' -42z'
  printf '[%i] ' ' -42z'
                 ^
[ stdin ]:18: printf expected an integer, got ' -42z'
osh43 printf + and space flags

stdout:
stderr: 
  [%+d]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%+d]\n' 42
         ^
[ stdin ]:1: osh printf doesn't support the '+' flag
  [%+d]\n
    ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%+d]\n' -42
         ^
[ stdin ]:2: osh printf doesn't support the '+' flag
  [% d]\n
    ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[% d]\n' 42
         ^
[ stdin ]:3: osh printf doesn't support the ' ' flag
  [% d]\n
    ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[% d]\n' -42
         ^
[ stdin ]:4: osh printf doesn't support the ' ' flag
osh-cpp43 printf + and space flags

stdout:
stderr: 
  [%+d]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%+d]\n' 42
         ^
[ stdin ]:1: osh printf doesn't support the '+' flag
  [%+d]\n
    ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%+d]\n' -42
         ^
[ stdin ]:2: osh printf doesn't support the '+' flag
  [% d]\n
    ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[% d]\n' 42
         ^
[ stdin ]:3: osh printf doesn't support the ' ' flag
  [% d]\n
    ^
[ printf arg at line 4 of [ stdin ] ]:1

  printf '[% d]\n' -42
         ^
[ stdin ]:4: osh printf doesn't support the ' ' flag
osh44 printf # flag

stdout:
---
stderr:
  [%#o][%#o]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%#o][%#o]\n' 0 42
         ^
[ stdin ]:1: osh printf doesn't support the '#' flag
  [%#x][%#x]\n
    ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%#x][%#x]\n' 0 42
         ^
[ stdin ]:2: osh printf doesn't support the '#' flag
  [%#X][%#X]\n
    ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[%#X][%#X]\n' 0 42
         ^
[ stdin ]:3: osh printf doesn't support the '#' flag
  [%.0f][%#.0f]\n
      ^
[ printf arg at line 5 of [ stdin ] ]:1

  printf '[%.0f][%#.0f]\n' 3 3
         ^
[ stdin ]:5: osh printf doesn't support floating point
  [%g][%#g]\n
    ^
[ printf arg at line 6 of [ stdin ] ]:1

  printf '[%g][%#g]\n' 3 3
         ^
[ stdin ]:6: osh printf doesn't support floating point
osh-cpp44 printf # flag

stdout:
---
stderr:
  [%#o][%#o]\n
    ^
[ printf arg at line 1 of [ stdin ] ]:1

  printf '[%#o][%#o]\n' 0 42
         ^
[ stdin ]:1: osh printf doesn't support the '#' flag
  [%#x][%#x]\n
    ^
[ printf arg at line 2 of [ stdin ] ]:1

  printf '[%#x][%#x]\n' 0 42
         ^
[ stdin ]:2: osh printf doesn't support the '#' flag
  [%#X][%#X]\n
    ^
[ printf arg at line 3 of [ stdin ] ]:1

  printf '[%#X][%#X]\n' 0 42
         ^
[ stdin ]:3: osh printf doesn't support the '#' flag
  [%.0f][%#.0f]\n
      ^
[ printf arg at line 5 of [ stdin ] ]:1

  printf '[%.0f][%#.0f]\n' 3 3
         ^
[ stdin ]:5: osh printf doesn't support floating point
  [%g][%#g]\n
    ^
[ printf arg at line 6 of [ stdin ] ]:1

  printf '[%g][%#g]\n' 3 3
         ^
[ stdin ]:6: osh printf doesn't support floating point
osh45 Runtime error for invalid integer

stdout:
status=1
status=1
stderr:
  printf '%d\n' $x
                ^~
[ stdin ]:2: printf expected an integer, got '3abc'
  printf '%d\n' xyz
                ^~~
[ stdin ]:4: printf expected an integer, got 'xyz'
osh-cpp45 Runtime error for invalid integer

stdout:
status=1
status=1
stderr:
  printf '%d\n' $x
                ^~
[ stdin ]:2: printf expected an integer, got '3abc'
  printf '%d\n' xyz
                ^~~
[ stdin ]:4: printf expected an integer, got 'xyz'
osh51 bash truncates long strftime string at 128

stdout:
4
40
120
124
128
stderr:
osh-cpp51 bash truncates long strftime string at 128

stdout:
4
40
120
124
128
stderr:
osh61 leading spaces are accepted in value given to %d %X, but not trailing spaces

stdout:
-123
status=0
status=1
---
63
status=0
255
status=0
FF
status=0
ff
status=0
stderr:
  printf '%d\n' ' -123 '
                ^
[ stdin ]:5: printf expected an integer, got ' -123 '
osh-cpp61 leading spaces are accepted in value given to %d %X, but not trailing spaces

stdout:
-123
status=0
status=1
---
63
status=0
255
status=0
FF
status=0
ff
status=0
stderr:
  printf '%d\n' ' -123 '
                ^
[ stdin ]:5: printf expected an integer, got ' -123 '