Created attachment 1478587 [details] Patch for man page, quit command and variable substitutions. Description of problem: Sorry, but there are about 3 'bugs' all tied together, but only the main 'swatch' command needs to be modified. (Patch attached.) 1) The swatch man page (perlpod) 'exec' section is misleading, and slightly incorrect. 2) The man page 'exec' section says that '$N' variables will be substituted. In fact only the first occurrence is substituted, and if other characters are present (e.g. 'abc$2') then it is not substituted at all. 3) Using the 'quit' action takes too long. In my tests it took around 3 minutes for swatch to actually quit. Version-Release number of selected component (if applicable): swatch-3.2.3-11.el7.noarch How reproducible: Relatively easily. Steps to Reproduce: 1. Install swatch and enter 'cd /tmp'. 2. Create the 'swatch.conf' file and enter watchfor /something(\d*)/ exec echo $1$1 quit 3. Run 'swatch --config-file=/tmp/swatch.conf --script-dir=. --awk-field-syntax' 4. From another terminal, run 'logger something32' 5. Stop swatch (or wait for it to timeout) 6. Modify the config file to use 'exec echo :$1 $1:' 7. Run swatch again 8. From another terminal, run 'logger something64' 9. Stop swatch 10. Modify the config file to use 'exec echo :$0 $*:' 11. Run swatch again 12. From another terminal, run 'logger something82' Actual results: (From step 4) output shown is 'Aug' (correct since the first part of the log file line begins with the date/time, but wrong in that the '$1' should appear twice. Adding '--dump-script' to the command-line shows that only one '$1' is substituted. Without the awk-field-syntax option, the correct output is shown. (From step 5) The 'quit' should execute immediately. It does not because it is actually waiting on the 'tail' command pipe used for input. The wait does eventually time out, not sure what causes that though (tail, perl, exit?) (From step 8) output shown is 'something64 Aug'. Because of the first colon (:), the $1 is not substituted correctly - it ends up displaying the last token of the log line ('something64'). The second $1 is again substituted correctly, but where have the colons gone? Without the awk-field-syntax, the correct output is shown. (From step 12) The output is correct. However, if the '--awk-field-option' is removed, an error is shown indicating that '$* is no longer supported'. The output also shows ':./.swatch_script.30491 :'. The '$0' is being interpreted as the actual swatch script being run. Expected results: (From step 4) output should be 'AugAug' when awk-field-option used, and '3232' when it isn't. (From step 5) The 'quit' should cause swatch to immediately exit cleanly. (From step 8) output should be ':Aug Aug:' when awk field option used, and ':64 64:' when it isn't used. (From step 12) With the awk fields option, the output should show the whole log line twice, separated by a space and beginning and ending with a colon. Without the awk fields option the output should be exactly the same. Additional info: The man page implies that with 'exec' $N variables can be used, but does not specify that their meaning is different depending on whether the '--awk-fields-syntax' option is used or not. It also implies that '$0' and '$*' will be substituted in all cases. This only happens when the awk fields option is used. However, since without the option these variables end up being interpreted by the shell, we will get the $0 interpreted as the swatch script name and $* as nothing (since no parameters are passed to the script). It is probably better, more user friendly, if $0 and $* are substituted in all cases (regardless of the awk fields option). There is no accounting taken for the fact that a variable may be escaped. Entering '\$0' for example, should not be interpreted (regardless of any options). Swatch currently calls 'exit' when the 'quit' action is seen. But this waits on the tail command to finish. It is better to call the 'goodbye' function already written into the script, and used to handle signals. This will then kill the tail pid, close any pipes and then exit. It happens immediately. The attached patch resolves all the above problems, and rewrites most of the 'exec' part of the man page. In addition, all the variables are substituted - provided they are not escaped. Currently, as shown in test step 4 above, only the first variable is substituted. Any others are ignored (so never shown in the output).
Got any other swatch fixes? :) Alternately, do you want to help maintain it?
(In reply to Tom "spot" Callaway from comment #1) > Got any other swatch fixes? :) > No, no more patches. That's it from us :-)
(In reply to Tom "spot" Callaway from comment #1) > > Alternately, do you want to help maintain it? > What I want is for the source code author (E. Todd Atkins) to make his mind up whether he is going to maintain the actual project or not. I, and others I gather, have tried to contact him over the past few years, using various email addresses, and have had no replies at all. Even a reject/bounce message would say something. The guy is still around it seems, but unless someone wants to phone him (at UCSB since that seems to be where he works), I think the only option is to clone swatch and move forward with that. If you mean maintain it as a redhat package, then I think I would rather not. Although we have no further patches for swatch, we do have some ideas about possible improvements. In addition, there are probably outstanding bugs and issues, possibly patches, on the sourceforge project page. All of these would need to go into the source code, and not end up being a large number of redhat patches applied to old code. In effect, this would create a 'redhat version' of swatch. It is a shame that the project has been left in such a mess. As mentioned though, perhaps cloning it is the only way forward. The downside is that swatch has been mentioned in a few books and articles, and people reading them, or just doing an Internet search, may not realise that there is a new project. That initial 'goodwill' created by swatch will be lost with the project.
swatch-3.2.3-23.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-7fbbad4197
swatch-3.2.3-23.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-7fbbad4197
swatch-3.2.3-23.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.