fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
99d63c21f
master
1# RUN: %fish %s 2 3printf "%d %d\n" 1 2 3 4# CHECK: 1 2 5# CHECK: 3 0 6 7printf "Hello %d %i %f %F %g %G\n" 1 2 3 4 5 6 8# CHECK: Hello 1 2 3.000000 4.000000 5 6 9 10printf "%x %X %o %u\n" 10 11 8 -1 11# CHECK: a B 10 18446744073709551615 12 13# %a has OS-dependent output - see #1139 14#printf "%a %A\n" 14 15 15 16printf "%c %s\n" a hello 17# CHECK: a hello 18 19printf "%c%c%c\n" hello … o 20# CHECK: h…o 21 22printf "%e %E\n" 5 6 23# CHECK: 5.000000e+00 6.000000E+00 24 25printf "%20d\n" 50 26# CHECK: 50 27 28printf "%-20d%d\n" 5 10 29# CHECK: 5 10 30 31printf "%*d\n" 10 100 32# CHECK: 100 33 34printf "%*s\n" 2147483648 abc 35# CHECKERR: invalid field width: 2147483648 36 37printf "%*s\n" -2147483649 abc 38# CHECKERR: invalid field width: -2147483649 39 40printf "%%\"\\\n" 41printf "%s\b%s\n" x y 42# CHECK: %"\nxy 43 44printf "abc\rdef\n" 45# CHECK: abc{{\r}}def 46 47printf "Msg1\fMsg2\n" 48# CHECK: Msg1{{\f}}Msg2 49 50printf "foo\vbar\vbaz\n" 51# CHECK: foobarbaz 52 53printf "\111 \x50 \u0051 \U00000052" 54echo 55# CHECK: I P Q R 56 57# \c escape means "stop printing" 58printf 'a\cb' 59echo 60# CHECK: a 61 62# Bogus printf specifier, should produce no stdout 63printf "%5" 10 2> /dev/null 64 65# Octal escapes produce literal bytes, not characters 66# \376 is 0xFE 67printf '\376' | display_bytes 68# CHECK: 0000000 376 69# CHECK: 0000001 70 71# Verify that floating point conversions and output work correctly with 72# different combinations of locales and floating point strings. See issue 73# #3334. This starts by assuming an locale using english conventions. 74printf '%e\n' "1.23" # should succeed, output should be 1.230000e+00 75# CHECK: 1.230000e+00 76 77printf '%e\n' "2,34" # should fail 78# CHECK: 2.000000e+00 79# CHECKERR: 2,34: value not completely converted (can't convert ',34') 80 81# Verify long long ints are handled correctly. See issue #3352. 82printf 'long hex1 %x\n' 498216206234 83# CHECK: long hex1 73ffffff9a 84printf 'long hex2 %X\n' 498216206234 85# CHECK: long hex2 73FFFFFF9A 86printf 'long hex3 %X\n' 0xABCDEF1234567890 87# CHECK: long hex3 ABCDEF1234567890 88printf 'long hex4 %X\n' 0xABCDEF12345678901 89printf '\n' 90# CHECK: long hex4 91# CHECKERR: 0xABCDEF12345678901: Number out of range 92printf 'long decimal %d\n' 498216206594 93# CHECK: long decimal 498216206594 94printf 'long signed %d\n' -498216206595 95# CHECK: long signed -498216206595 96printf 'long signed to unsigned %u\n' -498216206596 97# CHECK: long signed to unsigned 18446743575493345020 98 99# Just check that we print no error for no arguments 100printf 101echo $status 102# CHECK: 2 103 104# Verify numeric conversion still happens even if it couldn't be fully converted 105printf '%d\n' 15.1 106# CHECK: 15 107# CHECKERR: 15.1: value not completely converted (can't convert '.1') 108echo $status 109# CHECK: 1 110 111printf '%d\n' 07 112# CHECK: 7 113echo $status 114# CHECK: 0 115printf '%d\n' 08 116# CHECK: 0 117# CHECKERR: 08: value not completely converted (can't convert '8') 118# CHECKERR: Hint: a leading '0' without an 'x' indicates an octal number 119echo $status 120# CHECK: 1 121 122printf '%d\n' 0f 123# CHECK: 0 124# CHECKERR: 0f: value not completely converted (can't convert 'f') 125# CHECKERR: Hint: a leading '0' without an 'x' indicates an octal number 126echo $status 127# CHECK: 1 128 129printf '%d\n' 0g 130# CHECK: 0 131# CHECKERR: 0g: value not completely converted (can't convert 'g') 132echo $status 133# CHECK: 1 134 135printf '%d\n' abc 136# CHECKERR: abc: expected a numeric value 137 138printf '%d\n' "" 139# CHECK: 0 140 141printf '%f\n' 0x2 142# CHECK: 2.000000 143 144printf '%f\n' 0x2p3 145# CHECK: 16.000000 146 147printf '%.1f\n' -0X1.5P8 148# CHECK: -336.0 149 150printf '%.*f\n' 2147483648 1 151# CHECKERR: invalid precision: 2147483648 152 153printf '%lb\n' 1 154# CHECKERR: %lb: invalid conversion specification 155 156# Test that we ignore options 157printf -a 158printf --foo 159# CHECK: -a--foo 160echo 161 162set -l helpvar --help 163printf $helpvar 164echo 165# CHECK: --help 166 167printf --help 168echo 169# CHECK: --help 170 171# This is how mc likes to encode the directory we should cd to. 172printf '%b\n' '\0057foo\0057bar\0057' 173# CHECK: /foo/bar/ 174 175printf %18446744073709551616s 176# CHECKERR: Number out of range 177 178# Test non-ASCII behavior 179printf '|%3s|\n' ö 180# CHECK: | ö| 181printf '|%3s|\n' '🇺🇳' 182#CHECK: | 🇺🇳| 183printf '|%.3s|\n' '🇺🇳🇺🇳' 184#CHECK: |🇺🇳| 185printf '|%.3s|\n' 'a🇺🇳' 186#CHECK: |a🇺🇳| 187printf '|%.3s|\n' 'aa🇺🇳' 188#CHECK: |aa| 189printf '|%3.3s|\n' 'aa🇺🇳' 190#CHECK: | aa| 191printf '|%.1s|\n' 𒈙a 192#CHECK: |𒈙| 193printf '|%3.3s|\n' '👨👨👧👧' 194#CHECK: | 👨👨👧👧| 195 196printf '\xxyz' 197# CHECKERR: missing hexadecimal number in escape 198printf '\uxyz' 199# CHECKERR: Missing hexadecimal number in Unicode escape 200 201# Check handling of chars we use in our internal PUA encoding. 202printf '\uf641' | display_bytes 203# CHECK: 0000000 357 231 201 204# CHECK: 0000003 205 206printf '\U110000' 207# CHECKERR: Not a valid Unicode character: \U00110000 208 209# UTF-8 representation of \uf641 210printf '%s' \xef\x99\x81 | display_bytes 211# CHECK: 0000000 357 231 201 212# CHECK: 0000003