shellcheck on fixpermissions.sh#119
Conversation
Two issues. Fixed the empty if statement, not sure intent on case statement (getopts asks for -a, case checks -t)
|
Did your shell actually error on this? It crossed my mind that some shells won't like the empty statement but I never encountered it during testing. This change was only made to silence an error when you run the first time that will say there are no files to tail. I thought about negating the statement with a ! but I've had errors on other picky shells actually erroring out worse on that. It would probably be pretty easy to clean by just adding an echo saying "No log files found -- starting" |
|
I'm pretty sure my shell errored on this (parsing the following 'else' statement) [ubuntu 20.04, bash 5.0]. Adding the true in the empty |
|
Excellent, that makes sense. Thank you for reporting this! I ended up just adding a message that would say "No log files found" if none were present. I agree a -n would have been a good swap for this as well. The reason I went with the error message is that I'm trying to improve how much information the script is giving the user about what is happening and this seemed like a good opportunity. I had a lot of silent error conditions (a lot less now than a year or two ago) and while the users loved it just "working" without having to look at anything if anything went wrong it was almost impossible to troubleshoot. Even this little message might help me in some cases to know that the server has never ran successfully and created log files before or a few other scenarios that may arise. Thanks again! |
Two issues. Fixed the empty if statement, not sure intent on case statement (getopts asks for -a, case checks -t)