[Pkg-zfsonlinux-devel] Bug#1030316: Bug#1030316: trim script always exits 1 despite not failing
Scott Colby
debian at scott.scolby.com
Thu Feb 2 19:54:03 GMT 2023
On Thu, Feb 2, 2023, at 14:45, Petter Reinholdtsen wrote:
> [Scott Colby]
> > I believe this is caused by the final command of the script being
> > `zpool list ... | while read -r pool do ...; done`. When the output
> > of `zpool list` is exhausted, `read` returns an error, and thus the
> > script exits with that status. I have confirmed this by running the
> > script with `sh -x` and seeing that the last output line is
> > `+ read -r pool`.
>
> This sound strange. It is not according to my understanding of bourne
> shell scripting, and this oneliner describe how I believe it work:
>
> % ((set -x; echo foo|while read a; do a=$a; done); echo $?)
> + echo foo
> + read a
> + a=foo
> + read a
> 0
> %
You are correct. I was continuing to investigate this and I think
the actual case is that the previous call returns 1:
+ lsblk -dnr -o TRAN /dev/sda
+ [ sata = nvme ] # <-- this is false
+ return
+ read -r pool
As can be demonstrated by:
$ cat test.sh
#!/usr/bin/env sh
printf '1\n2\n3\n' | \
while read -r h
do
echo "aa$h"
false
done
$ sh -x test.sh
+ + printf 1\n2\n3\n
read -r h
+ echo aa1
aa1
+ false
+ read -r h
+ echo aa2
aa2
+ false
+ read -r h
+ echo aa3
aa3
+ false
+ read -r h
$ echo $?
1
I still think that this is a bug in the trim script though.
More information about the Pkg-zfsonlinux-devel
mailing list