printf

来自「实战Linux编程的原代码,希望对学驱动的人能有所帮助」· 代码 · 共 60 行

TXT
60 行
字号
#!/bin/sh# basic tests for printfprog=`pwd`/../../src/printfif test "$VERBOSE" = yes; then  set -x  $prog --versionfipwd=`pwd`t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0trap '(exit $?); exit $?' 1 2 13 15framework_failure=0mkdir -p $tmp || framework_failure=1cd $tmp || framework_failure=1if test $framework_failure = 1; then  echo "$0: failure in testing framework" 1>&2  (exit 1); exit 1fifail=0# This would fail (by printing the `--') for printf in sh-utils# and in coreutils 4.5.1.$prog -- 'foo\n' > out || fail=1cat <<\EOF > expfooEOFcmp out exp || fail=1test $fail = 1 && diff out exp 2> /dev/nullrm -f out exp# Until coreutils-4.5.10, this would elicit a segfault.$prog '1 %*sy\n' -3 x >  out || fail=1# Until coreutils-4.5.12, these would fail.POSIXLY_CORRECT=1 \$prog '2 \x'          >> out || fail=1; echo >> out$prog '3 \x40\n'      >> out || fail=1POSIXLY_CORRECT=1 \$prog '4 \x40\n'      >> out || fail=1$prog '5 % +d\n' 234  >> out || fail=1cat <<\EOF > exp1 x  y2 \x3 @4 \x405 +234EOFcmp out exp || fail=1test $fail = 1 && diff out exp 2> /dev/null(exit $fail); exit $fail

⌨️ 快捷键说明

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