fish-shell/tests/printf.in
2016-09-02 18:48:16 -07:00

44 lines
1.2 KiB
Fish

printf "Hello %d %i %f %F %g %G\n" 1 2 3 4 5 6
printf "%x %X %o %llu\n" 10 11 8 -1
# %a has OS-dependent output - see #1139
#printf "%a %A\n" 14 15
printf "%c %s\n" a hello
printf "%c%c%c\n" hello … o
printf "%e %E\n" 5 6
printf "%20d\n" 50
printf "%-20d%d\n" 5 10
printf "%*d\n" 10 100
printf "%%\"\\\n"
printf "%s\b%s\n" x y
printf "abc\rdef\n"
printf "Msg1\fMsg2\n"
printf "foo\vbar\vbaz\n"
printf "\111 \x50 \u0051 \U00000052"
echo
echo "Test escapes"
# \c escape means "stop printing"
printf 'a\cb'
echo
# Bogus printf specifier, should produce no stdout
printf "%5" 10 ^ /dev/null
# Octal escapes produce literal bytes, not characters
# \376 is 0xFE
printf '\376' | xxd -p
# Verify that floating point conversions and output work correctly with
# different combinations of locales and floating point strings. See issue
# #3334. This starts by assuming an locale using english conventions.
printf '%e\n' "1.23" # should succeed, output should be 1.230000e+00
printf '%e\n' "2,34" # should fail
set -x LC_NUMERIC fr_FR.UTF-8
printf '%e\n' "3,45" # should succeed, output should be 3,450000e+00
printf '%e\n' "4.56" # should succeed, output should be 4,560000e+00