[php-maint] Bug#770105: script using perl -0 or sed -z

Erik Auerswald auerswald at fg-networking.de
Fri Nov 21 08:29:03 UTC 2014


Hi,

the new line in the sessionclean script combines a lot of errrors:

[ -x /usr/bin/lsof ] && /usr/bin/lsof -w -l +d "${1}" -F0 | sed -zne "s/^n//p" | xargs -0i echo touch -c -h "'{}'"

* using -F0 instead of -F0n creates too much useless output
* the -n option to sed is not supported by the sed from Wheezy
* the output of lsof -F0 and the regular expression do not fit:
  lsof outputs the sequence \x00\x0a (a NUL byte, then a Newline), but the
  regex looks for a letter 'n' at the beginning of a line, e.g. directly
  following the NUL byte
* xargs does not call touch, but echo
* the quoting of the xargs replace-str results in adding single quotes to
  the file name given to touch

To fix these bugs you can use the following:

1) Using perl for Wheezy:

[ -x /usr/bin/lsof ] && /usr/bin/lsof -w -l +d "${1}" -F0n | perl -0ne 's/^\nn// and print' | xargs -0i touch -c -h {}

2) Using sed for Jessie and later:

[ -x /usr/bin/lsof ] && /usr/bin/lsof -w -l +d "${1}" -F0n | sed -zne 's/^\nn//p' | xargs -0i touch -c -h {}

In all likelihood the number of touch calls can be reduced as well by changing
the xargs call to not use -i (untested!):

xargs -0 touch -c -h

Anyway, please _test_ any of these changes before implementing them!

Thanks,
Erik



More information about the pkg-php-maint mailing list