⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printf1.sub

📁 android-w.song.android.widget
💻 SUB
字号:
LC_ALL=CLC_NUMERIC=Cunset vv# this should expand escape sequences in the format string, nothing elseprintf -v vv "\tone\n"printf "%s"  "$vv"# this should not cut off output after the \cprintf -v vv "one\ctwo\n"printf "%s"  "$vv"# and unrecognized backslash escapes should have the backslash preserverdprintf -v vv "4\.2\n"printf "%s"  "$vv"printf -v vv "no newline " ; printf "%s" "$vv" ; printf -v vv "now newline\n"printf "%s"  "$vv"# %% -> %printf -v vv "%%\n"printf "%s"  "$vv"# this was a bug caused by pre-processing the string for backslash escapes# before doing the `%' format processing -- all versions before bash-2.04printf -v vv "\045"printf "%s"  "$vv"echoprintf -v vv "\045d\n"printf "%s"  "$vv"# simple character outputprintf -v vv "%c\n" ABCDprintf "%s"  "$vv"# test simple string outputprintf -v vv "%s\n" unquotedprintf "%s"  "$vv"# test quoted string outputprintf -v vv "%s %q\n" unquoted quotedprintf "%s"  "$vv"printf -v vv "%s%10q\n" unquoted quotedprintf "%s"  "$vv"printf -v vv "%q\n" 'this&that'printf "%s"  "$vv"# make sure the format string is reused to use up argumentsprintf -v vv "%d " 1 2 3 4 5printf "%s"  "$vv"echo# make sure that extra format characters get null argumentsprintf -v vv "%s %d %d %d\n" onestringprintf "%s"  "$vv"printf -v vv "%s %d %u %4.2f\n" onestringprintf "%s"  "$vv"printf -v vv -- "--%s %s--\n" 4.2 ''printf "%s"  "$vv"printf -v vv -- "--%s %s--\n" 4.2printf "%s"  "$vv"# test %b escapes# 8 is a non-octal digit, so the `81' should be output#printf -v vv -- "--%b--\n" '\n\081'#printf "%s"  "$vv"printf -v vv -- "--%b--\n" '\t\0101'printf "%s"  "$vv"printf -v vv -- "--%b--\n" '\t\101'printf "%s"  "$vv"# these should all display `A7'printf -v vv "%b\n" '\01017'printf "%s"  "$vv"printf -v vv "%b\n" '\1017'printf "%s"  "$vv"printf -v vv "%b\n" '\x417'printf "%s"  "$vv"printf -v vv -- "--%b--\n" '\"abcd\"'printf "%s"  "$vv"printf -v vv -- "--%b--\n" "\'abcd\'"printf "%s"  "$vv"printf -v vv -- "--%b--\n" 'a\\x'printf "%s"  "$vv"printf -v vv -- "--%b--\n" '\x'printf "%s"  "$vv"Z1=$(printf -- "%b\n" '\a\b\e\f\r\v')Z2=$'\a\b\e\f\r\v'if [ "$Z1" != "$Z2" ]; then	printf "%s"  "whoops: printf -v vv %b and $'' differ" >&2fiunset Z1 Z2printf -v vv -- "--%b--\n" ''printf "%s"  "$vv"printf -v vv -- "--%b--\n"printf "%s"  "$vv"# the stuff following the \c should be ignored, as well as the rest# of the format stringprintf -v vv -- "--%b--\n" '4.2\c5.4\n'printf "%s"  "$vv"echo# unrecognized escape sequences should by displayed unchangedprintf -v vv -- "--%b--\n" '4\.2'printf "%s"  "$vv"# a bare \ should not be processed as an escape sequenceprintf -v vv -- "--%b--\n" '\'printf "%s"  "$vv"# make sure extra arguments are ignored if the format string doesn't# actually use themprintf -v vv "\n" 4.4 BSDprintf "%s"  "$vv"printf -v vv " " 4.4 BSDprintf "%s"  "$vv"echo# make sure that a fieldwidth and precision of `*' are handled rightprintf -v vv "%10.8s\n" 4.4BSDprintf "%s"  "$vv"printf -v vv "%*.*s\n" 10 8 4.4BSDprintf "%s"  "$vv"printf -v vv "%10.8q\n" 4.4BSDprintf "%s"  "$vv"printf -v vv "%*.*q\n" 10 8 4.4BSDprintf "%s"  "$vv"printf -v vv "%6b\n" 4.4BSDprintf "%s"  "$vv"printf -v vv "%*b\n" 6 4.4BSDprintf "%s"  "$vv"# we handle this crap with homemade code in printf -v vv.defprintf -v vv "%10b\n" 4.4BSDprintf "%s"  "$vv"printf -v vv -- "--%-10b--\n" 4.4BSDprintf "%s"  "$vv"printf -v vv "%4.2b\n" 4.4BSDprintf "%s"  "$vv"printf -v vv "%.3b\n" 4.4BSDprintf "%s"  "$vv"printf -v vv -- "--%-8b--\n" 4.4BSDprintf "%s"  "$vv"# test numeric conversions -- these four lines should printf "%s"  identicallyprintf -v vv "%d %u %i 0%o 0x%x 0x%X\n" 255 255 255 255 255 255printf "%s"  "$vv"printf -v vv "%d %u %i %#o %#x %#X\n" 255 255 255 255 255 255printf "%s"  "$vv"printf -v vv "%ld %lu %li 0%o 0x%x 0x%X\n" 255 255 255 255 255 255printf "%s"  "$vv"printf -v vv "%ld %lu %li %#o %#x %#X\n" 255 255 255 255 255 255printf "%s"  "$vv"printf -v vv "%10d\n" 42printf "%s"  "$vv"printf -v vv "%10d\n" -42printf "%s"  "$vv"printf -v vv "%*d\n" 10 42printf "%s"  "$vv"printf -v vv "%*d\n" 10 -42printf "%s"  "$vv"# test some simple floating point formatsprintf -v vv "%4.2f\n" 4.2printf "%s"  "$vv"printf -v vv "%#4.2f\n" 4.2printf "%s"  "$vv"printf -v vv "%#4.1f\n" 4.2printf "%s"  "$vv"printf -v vv "%*.*f\n" 4 2 4.2printf "%s"  "$vv"printf -v vv "%#*.*f\n" 4 2 4.2printf "%s"  "$vv"printf -v vv "%#*.*f\n" 4 1 4.2printf "%s"  "$vv"printf -v vv "%E\n" 4.2printf "%s"  "$vv"printf -v vv "%e\n" 4.2printf "%s"  "$vv"printf -v vv "%6.1E\n" 4.2printf "%s"  "$vv"printf -v vv "%6.1e\n" 4.2printf "%s"  "$vv"printf -v vv "%G\n" 4.2printf "%s"  "$vv"printf -v vv "%g\n" 4.2printf "%s"  "$vv"printf -v vv "%6.2G\n" 4.2printf "%s"  "$vv"printf -v vv "%6.2g\n" 4.2printf "%s"  "$vv"# test some of the more esoteric features of POSIX.1 printf -v vvprintf -v vv "%d\n" "'string'"printf "%s"  "$vv"printf -v vv "%d\n" '"string"'printf "%s"  "$vv"printf -v vv "%#o\n" "'string'"printf "%s"  "$vv"printf -v vv "%#o\n" '"string"'printf "%s"  "$vv"printf -v vv "%#x\n" "'string'"printf "%s"  "$vv"printf -v vv "%#X\n" '"string"'printf "%s"  "$vv"printf -v vv "%6.2f\n" "'string'"printf "%s"  "$vv"printf -v vv "%6.2f\n" '"string"'printf "%s"  "$vv"# output from these two lines had better be the sameprintf -v vv -- "--%6.4s--\n" abcdefghijklmnopqrstuvwxyzprintf "%s"  "$vv"printf -v vv -- "--%6.4b--\n" abcdefghijklmnopqrstuvwxyzprintf "%s"  "$vv"# and these two alsoprintf -v vv -- "--%12.10s--\n" abcdefghijklmnopqrstuvwxyzprintf "%s"  "$vv"printf -v vv -- "--%12.10b--\n" abcdefghijklmnopqrstuvwxyzprintf "%s"  "$vv"# tests for translating \' to ' and \\ to \# printf -v vv translates \' to ' in the format string...printf -v vv "\'abcd\'\n"printf "%s"  "$vv"# but not when the %b format specification is usedprintf -v vv "%b\n" \\\'abcd\\\'printf "%s"  "$vv"# but both translate \\ to \printf -v vv '\\abcd\\\n'printf "%s"  "$vv"printf -v vv "%b\n" '\\abcd\\'printf "%s"  "$vv"# this was reported as a bug in bash-2.03# these three lines should all printf "%s"  `26'printf -v vv "%d\n" 0x1aprintf "%s"  "$vv"printf -v vv "%d\n" 032printf "%s"  "$vv"printf -v vv "%d\n" 26printf "%s"  "$vv"# error messages# this should be an overflow, but error messages vary between systems# printf -v vv "%lu\n" 4294967296# ...but we cannot use this because some systems (SunOS4, for example),# happily ignore overflow conditions in strtol(3)#printf -v vv "%ld\n" 4294967296printf -v vv "%10"printf -v vv "ab%Mcd\n"# this caused an infinite loop in older versions of printf -v vvprintf -v vv "%y" 0# these should print a warning and `0', according to POSIX.2printf -v vv "%d\n" GNUprintf "%s"  "$vv"printf -v vv "%o\n" GNUprintf "%s"  "$vv"# failures in all bash versions through bash-2.05printf -v vv "%.0s" fooprintf "%s"  "$vv"printf -v vv "%.*s" 0 fooprintf "%s"  "$vv"printf -v vv '%.0b-%.0s\n' foo barprintf "%s"  "$vv"printf -v vv '(%*b)(%*s)\n' -4 foo -4 barprintf "%s"  "$vv"format='%'`printf '%0100384d' 0`'d\n' printf -v vv $format 0printf "%s"  "$vv"# failures in all bash versions through bash-3.0 - undercounted charactersunset vvprintf -v vv "  %s %s %s  \n%n" ab cd ef vvvprintf "%s" "$vv"echo $vvv# this doesn't work with printf -v vv(3) on all systems#printf -v vv "%'s\n" foo# test cases from an austin-group list discussion# prints ^G as an extensionprintf -v vv '%b\n' '\7'printf "%s"  "$vv"# prints ^Gprintf -v vv '%b\n' '\0007'printf "%s"  "$vv"# prints NUL then 7#printf -v vv '\0007\n'#printf "%s"  "$vv"# prints no more than two hex digitsprintf -v vv '\x07e\n'printf "%s"  "$vv"# additional backslash escapesprintf -v vv '\"\?\n'printf "%s"  "$vv"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -