Results for builtin-printf.test.sh

statusdashbashmkshzshashosh
pass 345233363239
ok 123528
N-I 1701511177
BUG 203230
total545454545454
casedashbashmkshzshashoshdescription
0pass pass ok ok pass pass printf with no args
detailsdetails
1N-I pass N-I N-I N-I pass printf -v %s
detailsdetailsdetailsdetails
2N-I pass N-I N-I N-I pass printf -v %q
detailsdetailsdetailsdetails
3N-I pass N-I N-I N-I pass printf -v a[1]
detailsdetailsdetailsdetails
4pass pass N-I N-I N-I pass printf -v syntax error
detailsdetailsdetails
5N-I pass N-I pass N-I pass dynamic declare instead of %s
detailsdetailsdetails
6N-I pass N-I N-I N-I ok dynamic declare instead of %q
detailsdetailsdetailsdetailsdetails
7N-I pass N-I N-I N-I ok printf -v dynamic scope
detailsdetailsdetailsdetailsdetails
8pass pass pass pass pass pass printf with too few arguments
9pass pass pass pass pass pass printf with too many arguments
10pass pass pass pass pass pass printf width strings
11pass pass pass pass pass pass printf integer
12pass pass pass pass pass pass printf %6.4d -- "precision" does padding for integers
13pass pass pass pass pass pass printf %6.4x X o
14pass pass pass pass pass pass %06d zero padding vs. %6.6d
15pass pass pass pass pass pass %06x %06X %06o
16pass pass ok pass pass pass %06s is no-op
details
17pass pass pass pass pass pass printf %6.4s does both truncation and padding
18pass pass N-I pass pass pass printf %6.0s and %0.0s
details
19pass pass N-I BUG pass pass printf %6.s and %0.s
detailsdetails
20pass pass pass pass pass pass printf %*.*s (width/precision from args)
21pass pass pass pass pass pass unsigned / octal / hex
22pass pass BUG pass pass pass unsigned / octal / hex big
details
23pass pass pass pass ok ok empty string (osh is more strict)
detailsdetails
24pass pass ok pass pass pass No char after ' => zero code point
details
25BUG pass BUG pass BUG pass Unicode char with '
detailsdetailsdetails
26pass pass pass pass pass pass Invalid UTF-8
27BUG pass BUG pass BUG ok Too large
detailsdetailsdetailsdetails
28pass pass pass pass pass N-I negative numbers with unsigned / octal / hex
details
29pass pass pass pass pass N-I printf floating point (not required, but they all implement it)
details
30pass pass pass pass pass N-I printf floating point with - and 0
details
31pass pass pass pass pass N-I printf eE fF gG
details
32N-I pass pass pass pass pass printf backslash escapes
details
33pass pass pass pass pass pass printf octal backslash escapes
34N-I pass pass pass N-I pass printf unicode backslash escapes
detailsdetails
35pass pass pass pass pass pass printf invalid backslash escape (is ignored)
36pass pass pass pass pass pass printf % escapes
37pass pass pass pass pass pass printf %b backslash escaping
38pass pass pass pass pass pass printf %b with \c early return
39N-I pass pass pass N-I N-I printf %c -- doesn't respect UTF-8! Bad.
detailsdetailsdetails
40ok pass pass pass pass ok printf invalid format
detailsdetails
41N-I ok pass ok N-I pass printf %q
detailsdetailsdetailsdetails
42N-I ok N-I ok N-I pass printf %6q (width)
detailsdetailsdetailsdetailsdetails
43pass pass pass ok ok ok printf negative numbers
detailsdetailsdetails
44pass pass pass pass pass N-I printf + and space flags
details
45pass pass pass pass pass N-I printf # flag
details
46pass pass pass BUG BUG ok Runtime error for invalid integer
detailsdetailsdetails
47N-I pass N-I N-I N-I pass %(strftime format)T
detailsdetailsdetailsdetails
48N-I pass N-I N-I N-I pass %(strftime format)T doesn't respect TZ if not exported
detailsdetailsdetailsdetails
49N-I pass N-I N-I N-I pass %(strftime format)T TZ in environ but not in shell's memory
detailsdetailsdetailsdetails
50N-I pass N-I N-I N-I pass %10.5(strftime format)T
detailsdetailsdetailsdetails
51pass pass pass pass pass pass Regression for 'printf x y'
52N-I pass N-I N-I N-I ok bash truncates long strftime string at 128
detailsdetailsdetailsdetailsdetails
53N-I pass pass ok N-I pass printf with explicit NUL byte
detailsdetailsdetails
226 passed, 21 OK, 67 not implemented, 10 BUG, 0 failed, 0 timeouts, 0 cases skipped

Details on runs that didn't PASS

mksh0 printf with no args

stdout:
stderr: 
printf: missing operand
Try 'printf --help' for more information.
zsh0 printf with no args

stdout:
stderr: 
printf: not enough arguments
dash1 printf -v %s

stdout:
['']
stderr:
dash: 2: printf: Illegal option -v
mksh1 printf -v %s

stdout:
-v['']
stderr:
printf: warning: ignoring excess arguments, starting with ‘foo’
zsh1 printf -v %s

stdout:
-v['']
stderr:
ash1 printf -v %s

stdout:
-v['']
stderr:
dash2 printf -v %q

stdout:
stderr: 
dash: 3: printf: Illegal option -v
mksh2 printf -v %q

stdout:
-v
stderr:
printf: warning: ignoring excess arguments, starting with ‘foo’
zsh2 printf -v %q

stdout:
-v
stderr:
ash2 printf -v %q

stdout:
-v
stderr:
dash3 printf -v a[1]

stdout:
stderr: 
dash: 1: Syntax error: "(" unexpected
mksh3 printf -v a[1]

stdout:
-vstatus=0
['a', 'b', 'c']
stderr:
printf: warning: ignoring excess arguments, starting with ‘a[1]’
zsh3 printf -v a[1]

stdout:
-vstatus=0
['a', 'b', 'c']
stderr:
ash3 printf -v a[1]

stdout:
stderr: 
ash: syntax error: unexpected "("
mksh4 printf -v syntax error

stdout:
-vstatus=0
stderr:
printf: warning: ignoring excess arguments, starting with ‘a[’
zsh4 printf -v syntax error

stdout:
-vstatus=0
stderr:
ash4 printf -v syntax error

stdout:
-vstatus=0
stderr:
dash5 dynamic declare instead of %s

stdout:
['']
stderr:
dash: 2: declare: not found
mksh5 dynamic declare instead of %s

stdout:
['']
stderr:
mksh: <stdin>[2]: declare: not found
ash5 dynamic declare instead of %s

stdout:
['']
stderr:
ash: declare: not found
dash6 dynamic declare instead of %q

stdout:
stderr: 
dash: 3: Bad substitution
mksh6 dynamic declare instead of %q

stdout:
stderr: 
mksh: <stdin>[3]: declare: not found
zsh6 dynamic declare instead of %q

stdout:
stderr: 
zsh: bad substitution
ash6 dynamic declare instead of %q

stdout:
stderr: 
ash: syntax error: bad substitution
osh6 dynamic declare instead of %q

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

stdout:
not implemented
stderr:
mksh7 printf -v dynamic scope

stdout:
not implemented
stderr:
zsh7 printf -v dynamic scope

stdout:
not implemented
stderr:
ash7 printf -v dynamic scope

stdout:
not implemented
stderr:
osh7 printf -v dynamic scope

stdout:
dollar=dollar
--
dollar='$'
mylocal=mylocal
--
dollar='$'
mylocal=
stderr:
mksh16 %06s is no-op

stdout:
(    42)
(   -42)
((status=1
stderr:
printf: %06s: invalid conversion specification
printf: %06s: invalid conversion specification
mksh18 printf %6.0s and %0.0s

stdout:
[      ]
[
stderr:
printf: %0.0s: invalid conversion specification
mksh19 printf %6.s and %0.s

stdout:
[      ]
[
stderr:
printf: %0.s: invalid conversion specification
zsh19 printf %6.s and %0.s

stdout:
[   foo]
[foo]
stderr:
mksh22 unsigned / octal / hex big

stdout:
[1]
[1]
[1]
[1]

[2147483647]
[17777777777]
[7fffffff]
[7FFFFFFF]

stderr:
ash23 empty string (osh is more strict)

stdout:
0
stderr:
ash: invalid number ''
osh23 empty string (osh is more strict)

stdout:
stderr: 
  printf '%d\n' ''
                ^
[ stdin ]:1: printf expected an integer, got ''
mksh24 No char after ' => zero code point

stdout:
0
0
stderr:
printf: ‘'’: expected a numeric value
printf: ‘"’: expected a numeric value
dash25 Unicode char with '

stdout:
ce
206
316

e4
228
344

stderr:
mksh25 Unicode char with '

stdout:
weird bug
stderr:
ash25 Unicode char with '

stdout:
ce
206
316

e4
228
344

stderr:
dash27 Too large

stdout:
too large
f4
244
364

stderr:
mksh27 Too large

stdout:
weird bug
stderr:
ash27 Too large

stdout:
too large
f4
244
364

stderr:
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
osh28 negative numbers with unsigned / octal / hex

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

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

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

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

  printf '[%.2f]\n' 3.14159
         ^
[ stdin ]:2: osh printf doesn't support floating point
  [%8.2f]\n
       ^
[ printf word 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 word at line 4 of [ stdin ] ]:1

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

  printf '[%-f]\n' 3.14159
         ^
[ stdin ]:5: osh printf doesn't support floating point
  [%-f]\n
     ^
[ printf word 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 word 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 word 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 word 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 word at line 4 of [ stdin ] ]:1

  printf '[%08.04f]\n' 3.14
         ^
[ stdin ]:4: Expected a printf format character
  [%-8.4f]\n
        ^
[ printf word 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 word 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 word at line 8 of [ stdin ] ]:1

  printf '[%-8.04f]\n' 3.14
         ^
[ stdin ]:8: Expected a printf format character
  [%-08.04f]\n
         ^
[ printf word 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 word at line 1 of [ stdin ] ]:1

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

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

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

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

  printf '[%G]\n' 3.14
         ^
[ stdin ]:5: osh printf doesn't support floating point
dash32 printf backslash escapes

stdout:
['a\tb']
['\\xE2\\x98\\xA0']
['$e']
['\x1f7']
stderr:
dash34 printf unicode backslash escapes

stdout:
['\\u2620']
['\\U0000065f']
stderr:
ash34 printf unicode backslash escapes

stdout:
['\\u2620']
['\\U0000065f']
stderr:
dash39 printf %c -- doesn't respect UTF-8! Bad.

stdout:
[$\u03bc\u03bc]
1
stderr:
ash39 printf %c -- doesn't respect UTF-8! Bad.

stdout:
[\u03bc\u03bc]
1
stderr:
osh39 printf %c -- doesn't respect UTF-8! Bad.

stdout:
[μμ]
0
stderr:
  %c
   ^
[ printf word at line 3 of [ stdin ] ]:1

  printf '%c' "$twomu" | wc --bytes
         ^
[ stdin ]:3: osh printf doesn't support single characters (bytes)
dash40 printf invalid format

stdout:
status=2
status=2
stderr:
dash: 1: printf: %z: invalid directive
dash: 3: printf: %-z: invalid directive
osh40 printf invalid format

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

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

  printf '%-z' 42
         ^
[ stdin ]:3: Invalid printf format character
dash41 printf %q

stdout:
[
stderr:
dash: 2: printf: %q: invalid directive
bash41 printf %q

stdout:
[a\ b]
stderr:
zsh41 printf %q

stdout:
[a\ b]
stderr:
ash41 printf %q

stdout:
[
stderr:
ash: %q]\n: invalid format
dash42 printf %6q (width)

stdout:
[[
stderr:
dash: 2: printf: %6q: invalid directive
dash: 3: printf: %1q: invalid directive
bash42 printf %6q (width)

stdout:
[  a\ b]
[a\ b]
stderr:
mksh42 printf %6q (width)

stdout:
[[
stderr:
printf: %6q: invalid conversion specification
printf: %1q: invalid conversion specification
zsh42 printf %6q (width)

stdout:
[  a\ b]
[a\ b]
stderr:
ash42 printf %6q (width)

stdout:
[[
stderr:
ash: %6q]\n: invalid format
ash: %1q]\n: invalid format
zsh43 printf negative numbers

stdout:
[-42] status=0
[-42] status=0
[-42] status=0
[-42] status=0
[-42] status=0
[-42] status=0
[0] status=1
[0] status=1
stderr:
zsh: bad math expression: operator expected at `z'
zsh: bad math expression: operator expected at `z'
ash43 printf negative numbers

stdout:
[-42] status=0
[-42] status=0
[-42] status=0
[-42] status=0
[0] status=1
[0] status=1
[0] status=1
[0] status=1
stderr:
ash: invalid number '-42 '
ash: invalid number '-42 '
ash: invalid number '-42z'
ash: invalid number '-42z'
osh43 printf negative numbers

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

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

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

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

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

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

stdout:
---
stderr:
  [%#o][%#o]\n
    ^
[ printf word 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 word 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 word 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 word 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 word at line 6 of [ stdin ] ]:1

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

stdout:
0
status=1
0
status=0
stderr:
zsh: bad math expression: operator expected at `abc'
ash46 Runtime error for invalid integer

stdout:
0
status=1
0
status=1
stderr:
ash: invalid number '3abc'
ash: invalid number 'xyz'
osh46 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'
dash47 %(strftime format)T

stdout:
status=2
stderr:
dash: 2: printf: %(: invalid directive
dash: 4: printf: %(: invalid directive
mksh47 %(strftime format)T

stdout:
status=1
stderr:
printf: %(: invalid conversion specification
printf: %(: invalid conversion specification
zsh47 %(strftime format)T

stdout:
status=1
stderr:
printf: %(: invalid directive
printf: %(: invalid directive
ash47 %(strftime format)T

stdout:
status=1
stderr:
ash: %(%Y-%m-%d)T\n: invalid format
ash: %(%Y-%m-%d)T\n: invalid format
dash48 %(strftime format)T doesn't respect TZ if not exported

stdout:
stderr: 
dash: 2: printf: %(: invalid directive
dash: 5: printf: %(: invalid directive
mksh48 %(strftime format)T doesn't respect TZ if not exported

stdout:
stderr: 
printf: %(: invalid conversion specification
printf: %(: invalid conversion specification
zsh48 %(strftime format)T doesn't respect TZ if not exported

stdout:
stderr: 
printf: %(: invalid directive
printf: %(: invalid directive
ash48 %(strftime format)T doesn't respect TZ if not exported

stdout:
stderr: 
ash: %(%Y-%m-%d %H:%M:%S)T\n: invalid format
ash: %(%Y-%m-%d %H:%M:%S)T\n: invalid format
dash49 %(strftime format)T TZ in environ but not in shell's memory

stdout:
stderr: 
dash: 2: printf: %(: invalid directive
dash: 6: printf: %(: invalid directive
mksh49 %(strftime format)T TZ in environ but not in shell's memory

stdout:
stderr: 
printf: %(: invalid conversion specification
printf: %(: invalid conversion specification
zsh49 %(strftime format)T TZ in environ but not in shell's memory

stdout:
stderr: 
printf: %(: invalid directive
printf: %(: invalid directive
ash49 %(strftime format)T TZ in environ but not in shell's memory

stdout:
stderr: 
ash: %(%Y-%m-%d %H:%M:%S)T\n: invalid format
ash: %(%Y-%m-%d %H:%M:%S)T\n: invalid format
dash50 %10.5(strftime format)T

stdout:
[[status=2
stderr:
dash: 2: printf: %10.5(: invalid directive
dash: 4: printf: %10.5(: invalid directive
mksh50 %10.5(strftime format)T

stdout:
[[status=1
stderr:
printf: %10.5(: invalid conversion specification
printf: %10.5(: invalid conversion specification
zsh50 %10.5(strftime format)T

stdout:
[[status=1
stderr:
printf: %10.5(: invalid directive
printf: %10.5(: invalid directive
ash50 %10.5(strftime format)T

stdout:
[[status=1
stderr:
ash: %10.5(%Y-%m-%d)T]\n: invalid format
ash: %10.5(%Y-%m-%d)T]\n: invalid format
dash52 bash truncates long strftime string at 128

stdout:
stderr: 
mksh52 bash truncates long strftime string at 128

stdout:
stderr: 
zsh52 bash truncates long strftime string at 128

stdout:
stderr: 
ash52 bash truncates long strftime string at 128

stdout:
stderr: 
osh52 bash truncates long strftime string at 128

stdout:
4
40
120
124
128
stderr:
dash53 printf with explicit NUL byte

stdout:
stderr: 
zsh53 printf with explicit NUL byte

stdout:
xzz
stderr:
ash53 printf with explicit NUL byte

stdout:
stderr: