/usr/local/etc/periodic/monthly/300.statistics of sysutils/bsdstats reports with an error message since 2011-08-01, like this: Doing login accounting: total 343.90 koie 343.90 Posting monthly OS statistics to rpt.bsdstats.org Posting monthly device statistics to rpt.bsdstats.org Posting monthly CPU statistics to rpt.bsdstats.org expr: not a decimal number: ' 43905' Posting monthly ports statistics to rpt.bsdstats.org -- End of monthly output -- Fix: at the head of 300.statistics, IFS is set to newline. I suspect /bin/sh has been changed for IFS or command substitution. # sample script set -x IFS=" " A=" 123" B=`expr $A + 1` echo $B % sh sample.sh + IFS=' ' + A=' 123' + expr ' 123' + 1 expr: not a decimal number: ' 123' + B='' + echo % Patch attached with submission follows: How-To-Repeat: sudo /usr/local/etc/periodic/monthly/300.statistics
KOIE Hidetaka <koie@suri.co.jp> writes: > --- 300.statistics.orig 2011-09-06 14:30:53.572040919 +0900 > +++ 300.statistics 2011-09-06 14:32:56.860042305 +0900 > @@ -171,7 +171,7 @@ > > > # Make the request > - string_length=`echo ${query_string} | wc -m` > + string_length=`echo ${query_string} | wc -m | sed 's/^ *//'` > string_length=`expr ${string_length} - 1` > > echo "POST ${url_prefix}/scripts/report_ports.php HTTP/1.0 Why not just eliminate expr(1) rather than trying to conform to its quirks? from expr(1) man page: The syntax of the expr command in general is historic and inconvenient. New applications are advised to use shell arithmetic rather than expr. and later · Leading white space and/or a plus sign before an otherwise valid positive numberic operand are allowed and will be ignored. After r223881 this does not seem to be true $ expr -- ' 1' + 1 expr: not a decimal number: ' 1' Exit 2 $ expr -e -- ' 1' + 1 2 default behavior is similar to `expr' from GNU coreutils $ gexpr -- ' 1' + 1 gexpr: non-integer argument Exit 2 http://svnweb.freebsd.org/base?view=revision&revision=223881
I agree on using builtin arith, and I misunderstood the problem.
Responsible Changed From-To: freebsd-ports-bugs->eadler I'll take it.
State Changed From-To: open->analyzed -
eadler 2011-09-25 21:35:26 UTC FreeBSD ports repository Modified files: sysutils/bsdstats Makefile sysutils/bsdstats/files 300.statistics.in Log: - use shell arithmetic instead of expr PR: ports/160504 Submitted by: KOIE Hidetaka <koie@suri.co.jp> Submitted by: h h <aakuusta@gmail.com> Approved by: bapt (mentor) Revision Changes Path 1.62 +1 -1 ports/sysutils/bsdstats/Makefile 1.45 +2 -2 ports/sysutils/bsdstats/files/300.statistics.in _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
State Changed From-To: analyzed->closed Committed. Thanks!