Solved Some shell scripts not working after upgrade from 12.1 to 12.2

I'm not 100% sure how to explain this as it's not my area of expertise and the person that wrote these scripts is not around anymore. Unfortunately, my boss does not want me to post the scripts so I'm not sure how much help can be offered but I thought I'd ask anyway and will answer any questions to the best of my ability :).

We have a few custom jail management scripts that work just fine on FreeBSD 12.1 but do not work after upgrading to FreeBSD 12.2 though I can't find any reason why they would not work. The error given is "1: parameter not set". The scripts all set "-euf" in the shebang line and after experimenting I found that if I add "set +u" at the beginning of the function that's causing the error and then "set -u" at the end of the function everything works fine. Of course I'm not sure if that's actually the proper fix or if it's fixing this one issue but causing others that I'm not noticing.

What really baffles me is why this would work on 12.1 and not 12.2, everything is configured exactly on the 12.2 machine as it is on the 12.1 machines. I've also read over the release notes and can't find any changes that would affect this but, like I said before, I'm not so great with this so could be missing something.

Sorry again for the vague question but any help or tips or guidance would be much appreciated.

Thank you!
 
The -u in the shebang will cause the script to exit if there is any attempt to expand (use) a variable, a positional parameter or the special parameter that is not set. So by unsetting that option (by doing set +u) you are allowing the script to run and ignore that fact that one of the variables is not set.

If you add set -x at the top of the script you'll be able to see what the script is executing as it executes it. This should help you narrow down the line which is giving you problems.
It could be that something external to the script has changed and a variable that should with something from the external tool isn't getting set. With extra output hopefully you'll be able to debug better :)
 
The -u in the shebang will cause the script to exit if there is any attempt to expand (use) a variable, a positional parameter or the special parameter that is not set. So by unsetting that option (by doing set +u) you are allowing the script to run and ignore that fact that one of the variables is not set.

If you add set -x at the top of the script you'll be able to see what the script is executing as it executes it. This should help you narrow down the line which is giving you problems.
It could be that something external to the script has changed and a variable that should with something from the external tool isn't getting set. With extra output hopefully you'll be able to debug better :)
Thank you! This really helped and I was able to track down the issue. At some point, someone cleaned up the code but missed one line, and evidently never tested it, and since this is the first time the updated code has been deployed the issue never showed up until now.

Thank you again!
 
Back
Top