basic
来自「实战Linux编程的原代码,希望对学驱动的人能有所帮助」· 代码 · 共 91 行
TXT
91 行
#!/bin/sh# make sure chgrp is reasonableif test "$VERBOSE" = yes; then set -x chgrp --versionfi. $srcdir/../envvar-check. $srcdir/../lang-default. $srcdir/../group-namespwd=`pwd`tmp=basic.$$trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0trap '(exit $?); exit' 1 2 13 15framework_failure=0mkdir $tmp || framework_failure=1cd $tmp || framework_failure=1if test $framework_failure = 1; then echo 'failure in testing framework' 1>&2 (exit 1); exitfifail=0set _ $groups; shiftg1=$1g2=$2mkdir dtouch f f2 d/f3chgrp $g1 f || fail=1chgrp $g2 f || fail=1chgrp $g2 f2 || fail=1chgrp -R $g1 d || fail=1( chgrp -c $g1 f chgrp -c $g2 f chgrp -c $g2 f chgrp --verbose $g1 f chgrp --verbose $g1 f chgrp --verbose --reference=f2 f chgrp -R --verbose $g2 d chgrp -R --verbose $g1 d chgrp -R -c $g2 d chgrp -R -c $g1 d chgrp -c $g2 d rm -f f touch f ln -s f symlink chgrp $g1 f chgrp $g2 symlink 2> /dev/null # This should not change the group of f. chgrp -c $g2 symlink 2> /dev/null chgrp -c $g2 f # This *should* change the group of f. # Though note that the diagnostic is misleading in that # it says the `group of `symlink'' has been changed. chgrp --dereference -c $g1 symlink) 2>&1 | sed "s/ $g1$/ G1/;s/ $g2$/ G2/" > actualcat <<\EOF > expectedchanged group of `f' to G1changed group of `f' to G2changed group of `f' to G1group of `f' retained as G1changed group of `f' to G2changed group of `d' to G2changed group of `d/f3' to G2changed group of `d' to G1changed group of `d/f3' to G1changed group of `d' to G2changed group of `d/f3' to G2changed group of `d' to G1changed group of `d/f3' to G1changed group of `d' to G2changed group of `f' to G2changed group of `symlink' to G1EOFcmp expected actual \ || { diff expected actual 1>&2; fail=1; }(exit $fail); exit
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?