> On Sunday, February 25th, 2024 at 6:20 PM, Bo Berglund > <bo.bergl...@gmail.com> wrote:
> On Sun, 25 Feb 2024 15:31:20 +0100, Bo Berglund bo.bergl...@gmail.com wrote: > > > On Sun, 25 Feb 2024 10:50:05 +0000, Peter Davis via Openvpn-users > > openvpn-users@lists.sourceforge.net wrote: > > > > > Hello, > > > I installed shellcheck and result is: > > > > > > # shellcheck script-events.sh > > > > > > In script-events.sh line 14: > > > if [[ "$script_type" == "client-connect" ]]; then > > > ^----------^ SC2154 (warning): script_type is referenced but not assigned. > > > > > > In script-events.sh line 15: > > > echo "$LOG_TIMESTAMP - $common_name connected with IP $trusted_ip" >> > > > "$LOG_FILE" > > > ^----------^ SC2154 (warning): common_name is referenced but not assigned. > > > ^---------^ SC2154 (warning): trusted_ip is referenced but not assigned. > > > > > > For more information: > > > https://www.shellcheck.net/wiki/SC2154 -- common_name is referenced but > > > not... > > > > That is because shellcheck cammot find the assignments to these variables... > > > > And that is because they are actually put into the environment by openvpn > > prior > > to calling the script. > > > > So these warnings are OK, since you know that on execution they will exist. > > > > I use shellcheck to find other errors that are hard to find for example > > after > > editing scripts of hundreds of lines in size. Esay to introduce unpaired > > if-fi > > etc.. > > > > I find it very useful prior to doing a test run to weed out typos and > > missing > > stuff like broken if fi pairs and mismatches of ( ) and [ ] etc. > > > > The result above says that there is no problem with the script itself > > syntactically, just that shellcheck does not know of the environment > > varibles > > provided by the caller. > > > HINT: > ----- > If you do not want this particular message to appear in a shellcheck output > then > you can add the following comment to the script on line #2: > > # shellcheck disable=SC2154 > > This will disable shellcheck from warning about these missing assignments. > It makes sense to add into scripts that use variables supplied in the > environment so this line could help in this case but not be used in other > cases. > > > -- > Bo Berglund > Developer in Sweden > > > > _______________________________________________ > Openvpn-users mailing list > Openvpn-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openvpn-users Hi, Thanks again. But my problem is that the script doesn't work at all. How do I find the cause? _______________________________________________ Openvpn-users mailing list Openvpn-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-users