-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qmail-qstat: simplify the code #234
Conversation
@mbhangui your Indimail uses big-todo IIRC, could you check if this works properly there? |
This works for big-todo because it uses find. The earlier script didn't work because it expected all files to be in queue/todo directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, seal of approval
Maybe if someone does something funky with symlinks, then an extra -L
flag to find could be useful though?
messfiles=`find QMAIL/queue/mess/* -type f | wc -l` | ||
todofiles=`find QMAIL/queue/todo -type f | wc -l` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wc -w
to wc -l
make sense, find produces one result per line.
It is all based upon the absence of spaces in file names here anyway.
Maybe another case where -type f
was not widely available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect someone that does such special things to the queue to be able to hack this script as well.
|
First, do not chdir to the qmail directory, but instead pass the absolute path to the find commands. Then tell find to only output files, and count them, instead of counting everything and then substracting the directories. If there is anything beyond a plain file somewhere in the queue this would have been counted before and is no longer counted now, but the presence of anything else can be considered a bug in itself. When someone is using the big-todo patch this would collide, but for good: the new version can work with both the original and the big-todo queue style without modifications. While at it quote the arguments to echo just to be sure. The additional "-type f" argument can already be found in the AT&T System V user manual from 1986, so it's safe to assume it's presence.
See the commits for a detailed description, but boils down to:
find -type f
to just count files and avoid much complication in the script