On 7/13/26 12:18, James Youngman wrote:
Thanks for these fixes. I sent a couple of follow-up improvements.
Hi James,
thanks - still 'tests/find/ls-format-file.sh' is failing here.
The relevant part is:
+ find lsme -printf '%9i %6b %M %3n %-8u %-8g %8s %3Tb %2Td %5TY %p\n'
+ compare printf-output.txt output.txt
+ compare_dev_null_ printf-output.txt output.txt
+ test 2 = 2
+ test xprintf-output.txt = x/dev/null
+ test xoutput.txt = x/dev/null
+ return 2
+ case $? in
+ compare_ printf-output.txt output.txt
+ LC_ALL=C
+ diff -u printf-output.txt output.txt
--- printf-output.txt 2026-07-22 23:25:29.952544221 +0200
+++ output.txt 2026-07-22 23:25:29.941544072 +0200
@@ -1 +1 @@
- 6042709 8 -rw------- 1 berny users 765 Mar 14 1992 lsme
+ 6042709 4 -rw------- 1 berny users 765 Mar 14 1992 lsme
+ fail=1
This means -printf '%b' yields 8 because it's using 512 blocksize while -ls uses
a blocksize of 1024.
Here is the output for -ls, %b, %k and system ls for comparison - depending
on POSIXLY_CORRECT:
$ env POSIXLY_CORRECT=1 \
find/find lsme \
-ls \
-printf '%9i %6b %M %3n %-8u %-8g %8s %3Tb %2Td %5TY %p\n' \
-printf "%9i %6k %M %3n %-8u %-8g %8s %3Tb %2Td %5TY %p\n" \
-exec /bin/ls -dils '{}' \;
5780631 8 -rw-r--r-- 1 berny users 765 Jul 22 20:54 lsme
5780631 8 -rw-r--r-- 1 berny users 765 Jul 22 2026 lsme
5780631 4 -rw-r--r-- 1 berny users 765 Jul 22 2026 lsme
5780631 8 -rw-r--r-- 1 berny users 765 Jul 22 20:54 lsme
$ env -u POSIXLY_CORRECT \
find/find lsme \
-ls \
-printf '%9i %6b %M %3n %-8u %-8g %8s %3Tb %2Td %5TY %p\n' \
-printf "%9i %6k %M %3n %-8u %-8g %8s %3Tb %2Td %5TY %p\n" \
-exec /bin/ls -dils '{}' \;
5780631 4 -rw-r--r-- 1 berny users 765 Jul 22 20:54 lsme
5780631 8 -rw-r--r-- 1 berny users 765 Jul 22 2026 lsme
5780631 4 -rw-r--r-- 1 berny users 765 Jul 22 2026 lsme
5780631 4 -rw-r--r-- 1 berny users 765 Jul 22 20:54 lsme
FWIW: I'm using an 'ext4' filesystem here, and this is the output of the
statx() syscall:
$ strace -ve statx /bin/stat lsme 2>&1 | sed 1q
statx(AT_FDCWD, "lsme",
AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW|AT_NO_AUTOMOUNT, STATX_ALL, \
{stx_mask=STATX_ALL|STATX_MNT_ID, \
stx_blksize=4096, \
stx_attributes=0, \
stx_nlink=1, \
stx_uid=1000, \
stx_gid=100, \
stx_mode=S_IFREG|0644, \
stx_ino=5780631, \
stx_size=765, \
stx_blocks=8, \
stx_attributes_mask=STATX_ATTR_COMPRESSED|STATX_ATTR_IMMUTABLE|STATX_ATTR_APPEND|STATX_ATTR_NODUMP|\
STATX_ATTR_ENCRYPTED|STATX_ATTR_AUTOMOUNT|STATX_ATTR_MOUNT_ROOT|STATX_ATTR_VERITY|STATX_ATTR_DAX,
\
stx_atime={tv_sec=1784746447, tv_nsec=353879572} /*
2026-07-22T20:54:07.353879572+0200 */, \
stx_btime={tv_sec=1784746447, tv_nsec=353879572} /*
2026-07-22T20:54:07.353879572+0200 */, \
stx_ctime={tv_sec=1784746447, tv_nsec=354879586} /*
2026-07-22T20:54:07.354879586+0200 */, \
stx_mtime={tv_sec=1784746447, tv_nsec=354879586} /*
2026-07-22T20:54:07.354879586+0200 */, \
stx_rdev_major=0, \
stx_rdev_minor=0, \
stx_dev_major=8, \
stx_dev_minor=5, \
stx_mnt_id=0x2a}) = 0
I'm confused why this test is working for you. Can you reproduce this?
Do you have a different filesystem type with other block sizes?
Changing from %b to %k helps here, but I'd rather like to understand what
happens on your side.
diff --git a/tests/find/ls-format-file.sh b/tests/find/ls-format-file.sh
index cee3737e..b6242222 100755
--- a/tests/find/ls-format-file.sh
+++ b/tests/find/ls-format-file.sh
@@ -309,7 +309,7 @@ fi
# Generate "by hand" in the file printf-output.txt some output which
# should match the output of -ls.
rm -f -- printf-output.txt
-if ! find "${testfile}" -printf '%9i %6b %M %3n %-8u %-8g %8s %3Tb %2Td %5TY
%p\n' > printf-output.txt
+if ! find "${testfile}" -printf '%9i %6k %M %3n %-8u %-8g %8s %3Tb %2Td %5TY
%p\n' > printf-output.txt
then
framework_failure_ "unable to create printf-output.txt"
fi
Thanks & have a nice day,
Berny++ initial_cwd_=/home/berny/findutils
+++ testdir_prefix_
+++ printf gt
++ pfx_=gt
+++ mktempd_ /home/berny/findutils gt-ls-format-file.sh.XXXX
+++ case $# in
+++ destdir_=/home/berny/findutils
+++ template_=gt-ls-format-file.sh.XXXX
+++ MAX_TRIES_=4
+++ case $destdir_ in
+++ destdir_slash_=/home/berny/findutils/
+++ case $template_ in
++++ unset TMPDIR
+++ d=/home/berny/findutils/gt-ls-format-file.sh.sGo8
+++ case $d in
+++ :
+++ test -d /home/berny/findutils/gt-ls-format-file.sh.sGo8
++++ ls -dgo /home/berny/findutils/gt-ls-format-file.sh.sGo8
+++ perms='drwx------ 2 4096 Jul 22 23:49 /home/berny/findutils/gt-ls-format-file.sh.sGo8'
+++ case $perms in
+++ :
+++ echo /home/berny/findutils/gt-ls-format-file.sh.sGo8
+++ return
++ test_dir_=/home/berny/findutils/gt-ls-format-file.sh.sGo8
++ cd /home/berny/findutils/gt-ls-format-file.sh.sGo8
++ case $srcdir in
++ srcdir=../.
++ builddir=..
++ export srcdir builddir
++ gl_init_sh_nl_=$'\n'
++ IFS=$' \t\n'
++ for sig_ in 1 2 3 13 15
+++ expr 1 + 128
++ eval 'trap '\''Exit 129'\'' 1'
+++ trap 'Exit 129' 1
++ for sig_ in 1 2 3 13 15
+++ expr 2 + 128
++ eval 'trap '\''Exit 130'\'' 2'
+++ trap 'Exit 130' 2
++ for sig_ in 1 2 3 13 15
+++ expr 3 + 128
++ eval 'trap '\''Exit 131'\'' 3'
+++ trap 'Exit 131' 3
++ for sig_ in 1 2 3 13 15
+++ expr 13 + 128
++ eval 'trap '\''Exit 141'\'' 13'
+++ trap 'Exit 141' 13
++ for sig_ in 1 2 3 13 15
+++ expr 15 + 128
++ eval 'trap '\''Exit 143'\'' 15'
+++ trap 'Exit 143' 15
++ saved_IFS=$' \t\n'
++ IFS=:
++ new_PATH=
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /home/berny/findutils/find/.
++ new_PATH=/home/berny/findutils/find
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /home/berny/findutils/locate/.
++ new_PATH=/home/berny/findutils/find:/home/berny/findutils/locate
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /home/berny/findutils/xargs/.
++ new_PATH=/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /home/berny/bin/.
++ new_PATH=/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /usr/local/bin/.
++ new_PATH=/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /usr/bin/.
++ new_PATH=/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin:/usr/bin
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /bin/.
++ new_PATH=/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin:/usr/bin:/bin
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /sbin/.
++ new_PATH=/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin:/usr/bin:/bin:/sbin
++ for dir in $PATH
++ IFS=$' \t\n'
++ case "$dir" in
++ test -d /usr/sbin/.
++ new_PATH=/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin
++ IFS=$' \t\n'
++ PATH=/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin
++ export PATH
++ trap remove_tmp_ EXIT
+ fu_path_prepend_
+ path_prepend_ .././find .././locate .././xargs
+ test 3 '!=' 0
+ path_dir_=.././find
+ case $path_dir_ in
+ abs_path_dir_=/home/berny/findutils/.././find
+ case $abs_path_dir_ in
+ PATH=/home/berny/findutils/.././find:/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin
+ create_exe_shims_ /home/berny/findutils/.././find
+ case $EXEEXT in
+ return 0
+ shift
+ test 2 '!=' 0
+ path_dir_=.././locate
+ case $path_dir_ in
+ abs_path_dir_=/home/berny/findutils/.././locate
+ case $abs_path_dir_ in
+ PATH=/home/berny/findutils/.././locate:/home/berny/findutils/.././find:/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin
+ create_exe_shims_ /home/berny/findutils/.././locate
+ case $EXEEXT in
+ return 0
+ shift
+ test 1 '!=' 0
+ path_dir_=.././xargs
+ case $path_dir_ in
+ abs_path_dir_=/home/berny/findutils/.././xargs
+ case $abs_path_dir_ in
+ PATH=/home/berny/findutils/.././xargs:/home/berny/findutils/.././locate:/home/berny/findutils/.././find:/home/berny/findutils/find:/home/berny/findutils/locate:/home/berny/findutils/xargs:/home/berny/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin
+ create_exe_shims_ /home/berny/findutils/.././xargs
+ case $EXEEXT in
+ return 0
+ shift
+ test 0 '!=' 0
+ export PATH
+ print_ver_ find
+ require_built_ find
+ skip_=no
+ for i in "$@"
+ case " $built_programs " in
+ test no = yes
+ test yes = yes
+ local i
+ for i in $*
+ env find --version
find (GNU findutils) 4.11.0.23-ffa1-modified
Copyright (C) 2026 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Eric B. Decker, James Youngman, Bernhard Voelker,
and Kevin Dalley.
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=1)
+ unset POSIXLY_CORRECT
+ LC_ALL=C
+ export LC_ALL
+ unset LANG
+ fail=0
++ id -u -n
+ user_owner=berny
+ '[' -z berny ']'
+ umask 077
+ testfile=lsme
+ filesize=765
+ rm -f -- lsme
+ touch -t 199203141900.01 lsme
++ choose_distinct_group
++ chosen=N
++ unset group_name
+++ groups
++ for group_name in $(groups)
++ '[' users '!=' berny ']'
++ printf '%s\n' users
++ chosen=Y
++ break
++ '[' Y = N ']'
+ group_owner=users
+ '[' -z users ']'
+ chgrp users lsme
++ find lsme -printf '%i\n'
+ inum=6042709
++ ls -s lsme
++ sed -e s/lsme//g
+ blocks_expected='4 '
+ find lsme -ls
+ echo 'output of find lsme -ls:'
output of find lsme -ls:
+ cat output.txt
6042709 4 -rw------- 1 berny users 765 Mar 14 1992 lsme
+ echo 'same thing in od -c format:'
same thing in od -c format:
+ od -c output.txt
0000000 6 0 4 2 7 0 9 4
0000020 - r w - - - - - - - 1
0000040 b e r n y u s e r s
0000060 7 6 5 M a r 1
0000100 4 1 9 9 2 l s m e \n
0000115
++ sed -n -e '$ s/.*//p'
++ wc -c
+ '[' 1 -eq 0 ']'
+ grep -e ' lsme$'
++ id -un
+ awk -v ME=ls-format-file.sh -v filename_expected=lsme -v inodenum=6042709 -v 'blocks_expected=4 ' -v filesize=765 -v uowner=berny -v gowner=users $'\nBEGIN {\n rv=2\n}\n{\n for (i=1; i<=NF; ++i) {\n printf("%s: info: record %d field %2d contains %s\\n", ME, NR, i, $i);\n }\n}\nNR == 2 {\n rv=1\n printf("%s: failed test: Too many lines of output\\n", ME);\n}\nNR == 1 {\n rv=0\n\n st_ino=$1;\n st_blocks=$2;\n symbolic_st_mode="" $3;\n st_nlink=$4;\n st_uid=$5;\n st_gid=$6;\n st_size=$7;\n st_mtime_monthname=$8;\n st_mtime_monthday=$9;\n st_mtime_year=$10;\n filename_got=$11;\n\n printf("%s: info: checking output of -ls (which was [%s])\\n", ME, $0);\n\n # field 1: inode number\n if (st_ino != inodenum) {\n rv=1\n printf("%s: failed test: expected inode number %d, got %s\\n", ME, inodenum, $1);\n }\n\n # field 2: size in blocks\n if (st_blocks != blocks_expected) {\n rv=1\n printf("%s: failed test: expected block count %d got %d\\n", ME, blocks_expected, st_blocks);\n } else {\n printf("%s: block count %d looks OK\\n", ME, st_blocks);\n }\n\n # field 3 is the symbolic mode; we allow a final +\n # in case there is somehow a non-default ACL on the file.\n if (symbolic_st_mode != "-rw-------" && symbolic_st_mode != "-rw-------+") {\n rv=1\n printf("%s: failed test: expected symbolic mode [-rw-------], got [%s]\\n", ME, symbolic_st_mode);\n }\n # field 4 is the link count\n if (st_nlink != 1) {\n rv=1\n printf("%s: failed test: expected link count 1, got %s\\n", ME, st_nlink);\n } else {\n printf("%s: link count %s looks OK\\n", ME, st_nlink);\n }\n # field 5 is the owner\n if (st_uid != uowner) {\n rv=1\n printf("%s: failed test: expected owner [%s], got [%s]\\n", ME, uowner, st_uid);\n } else {\n printf("%s: owner %s looks OK\\n", ME, st_uid);\n }\n # field 6 is the group owner\n if (st_gid != gowner) {\n rv=1\n printf("%s: failed test: expected group owner [%s], got [%s]\\n", ME, gowner, st_gid);\n } else {\n printf("%s: group owner %s looks OK\\n", ME, st_gid);\n }\n # field 7 is the size in bytes\n if (st_size != filesize) {\n rv=1\n printf("%s: failed test: expected file size %d, got %s\\n", ME, filesize, st_size);\n } else {\n printf("%s: file size %s looks OK\\n", ME, st_size);\n }\n # field 8 is the month of the mtime\n if (st_mtime_monthname != "Mar") {\n rv=1\n printf("%s: failed test: expected mtime month Mar, got %s\\n", ME, st_mtime_monthname);\n } else {\n printf("%s: mtime month %s looks OK\\n", ME, st_mtime_monthname);\n }\n # field 9 is the month-day of the mtime\n if (st_mtime_monthday != 14) {\n rv=1\n printf("%s: failed test: expected mtime month-day 14, got %s\\n", ME, st_mtime_monthday);\n } else {\n printf("%s: mtime month-day %s looks OK\\n", ME, st_mtime_monthday);\n }\n # field 10 is the year of the mtime\n if (st_mtime_year != 1992) {\n rv=1\n printf("%s: failed test: expected mtime year 1992, got %s\\n", ME, st_mtime_year);\n } else {\n printf("%s: mtime year %s looks OK\\n", ME, st_mtime_year);\n }\n # field 11 is the file name\n if (filename_got != filename_expected) {\n rv=1\n printf("%s: failed test: expected filename %s, got %s\\n", ME, filename, $11);\n } else {\n printf("%s: file name %s looks OK\\n", ME, $11);\n }\n}\nEND {\n printf("%s: Finished AWK tests: exiting with status %d\\n", ME, rv);\n exit rv;\n}\n'
ls-format-file.sh: info: record 1 field 1 contains 6042709
ls-format-file.sh: info: record 1 field 2 contains 4
ls-format-file.sh: info: record 1 field 3 contains -rw-------
ls-format-file.sh: info: record 1 field 4 contains 1
ls-format-file.sh: info: record 1 field 5 contains berny
ls-format-file.sh: info: record 1 field 6 contains users
ls-format-file.sh: info: record 1 field 7 contains 765
ls-format-file.sh: info: record 1 field 8 contains Mar
ls-format-file.sh: info: record 1 field 9 contains 14
ls-format-file.sh: info: record 1 field 10 contains 1992
ls-format-file.sh: info: record 1 field 11 contains lsme
ls-format-file.sh: info: checking output of -ls (which was [ 6042709 4 -rw------- 1 berny users 765 Mar 14 1992 lsme])
ls-format-file.sh: block count 4 looks OK
ls-format-file.sh: link count 1 looks OK
ls-format-file.sh: owner berny looks OK
ls-format-file.sh: group owner users looks OK
ls-format-file.sh: file size 765 looks OK
ls-format-file.sh: mtime month Mar looks OK
ls-format-file.sh: mtime month-day 14 looks OK
ls-format-file.sh: mtime year 1992 looks OK
ls-format-file.sh: file name lsme looks OK
ls-format-file.sh: Finished AWK tests: exiting with status 0
+ rv=0
+ echo 'Awk exit status was 0'
Awk exit status was 0
+ '[' 0 -ne 0 ']'
+ rm -f -- printf-output.txt
+ find lsme -printf '%9i %6b %M %3n %-8u %-8g %8s %3Tb %2Td %5TY %p\n'
+ compare printf-output.txt output.txt
+ compare_dev_null_ printf-output.txt output.txt
+ test 2 = 2
+ test xprintf-output.txt = x/dev/null
+ test xoutput.txt = x/dev/null
+ return 2
+ case $? in
+ compare_ printf-output.txt output.txt
+ LC_ALL=C
+ diff -u printf-output.txt output.txt
--- printf-output.txt 2026-07-22 23:49:54.879408249 +0200
+++ output.txt 2026-07-22 23:49:54.868408101 +0200
@@ -1 +1 @@
- 6042709 8 -rw------- 1 berny users 765 Mar 14 1992 lsme
+ 6042709 4 -rw------- 1 berny users 765 Mar 14 1992 lsme
+ fail=1
+ warn_ 'ls-format-file.sh: the output of the -ls action seems to be incorrect'
+ case $IFS in
+ printf '%s\n' 'ls-format-file.sh: the output of the -ls action seems to be incorrect'
ls-format-file.sh: the output of the -ls action seems to be incorrect
+ test 9 = 2
+ local 'args=ls-format-file.sh: the output of the -ls action seems to be incorrect'
+ local 'firstline=ls-format-file.sh: the output of the -ls action seems to be incorrect'
+ printf '%s\n' 'ls-format-file.sh: the output of the -ls action seems to be incorrect'
+ Exit 1
+ set +e
+ exit 1
+ exit 1
+ remove_tmp_
+ __st=1
+ cleanup_
+ :
+ test '' = yes
+ cd /home/berny/findutils
+ chmod -R u+rwx /home/berny/findutils/gt-ls-format-file.sh.sGo8
+ rm -rf /home/berny/findutils/gt-ls-format-file.sh.sGo8
+ exit 1
FAIL tests/find/ls-format-file.sh (exit status: 1)