summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/include.rc42
1 files changed, 25 insertions, 17 deletions
diff --git a/tests/include.rc b/tests/include.rc
index bcaafb90f66..82527856902 100644
--- a/tests/include.rc
+++ b/tests/include.rc
@@ -323,28 +323,36 @@ stat -c %s /dev/null > /dev/null 2>&1 || {
if [ "x${format}" = "x" ] ; then
`which stat` $f
else
- echo ${format} | sed "
- s/%u/`$( which stat ) -f %u $f`/g;
- s/%g/`$( which stat ) -f %g $f`/g;
- s/%a/`$( which stat ) -f %p $f |sed 's/^..//; s/^0//'`/g;
- s/%A/`ls -l $f|awk '{print $1}'`/g;
- s/%s/`$( which stat ) -f %z $f`/g;
- s/%h/`$( which stat ) -f %l $f`/g;
- s/%F/`$( which stat ) -f %HT $f | sed '
+ cmd=""
+ case $format in
+ *%u*) cmd="${cmd} s/%u/`$( which stat ) -f %u $f`/g;" ;&
+ *%g*) cmd="${cmd} s/%g/`$( which stat ) -f %g $f`/g;" ;&
+ *%a*) cmd="${cmd} s/%a/`$( which stat ) -f %p $f |
+ sed 's/^..//; s/^0//'`/g;" ;&
+ *%A*) cmd="${cmd} s/%A/`ls -ld $f|awk '{print $1}'`/g;" ;&
+ *%s*) cmd="${cmd} s/%s/`$( which stat ) -f %z $f`/g;" ;&
+ *%h*) cmd="${cmd} s/%h/`$( which stat ) -f %l $f`/g;" ;&
+ *%F*) cmd="${cmd} s/%F/`$( which stat ) -f %HT $f | sed '
s/Directory/directory/;
- s/Fifo file/fifo/;
+ s/Fifo File/fifo/;
s/Symbolic Link/symbolic link/;
s/Regular File/regular file/;
s/Block Device/block special file/;
s/Character Device/character special file/;
- ' | sed \"$(
- test -s $f && echo 's/regular file/regular empty file/g'
- )\"`/g;
- s|%n|`$( which stat ) -f %N $f`|g;
- s/%Y/`$( which stat ) -f %m $f`/g;
- s/%b/`$( which stat ) -f %b $f`/g;
- s/%B/512/g;
- "
+ ' | sed \"$(
+ test -s $f || echo 's/regular file/regular empty file/g'
+ )\"`/g;" ;&
+ *%n*) cmd="${cmd} s|%n|`$( which stat ) -f %N $f`|g;" ;&
+ *%Y*) cmd="${cmd} s/%Y/`$( which stat ) -f %m $f`/g;" ;&
+ *%X*) cmd="${cmd} s/%X/`$( which stat ) -f %a $f`/g;" ;&
+ *%Z*) cmd="${cmd} s/%Z/`$( which stat ) -f %c $f`/g;" ;&
+ *%b*) cmd="${cmd} s/%b/`$( which stat ) -f %b $f`/g;" ;&
+ *%B*) cmd="${cmd} s/%B/512/g;" ;&
+ *%t*) cmd="${cmd} s/%t/`$( which stat ) -f %XHr $f`/g;" ;&
+ *%T*) cmd="${cmd} s/%T/`$( which stat ) -f %XLr $f`/g;" ;&
+ esac
+
+ `which stat` -f "`echo $format|sed \"$cmd\"`" $f
fi
}
}