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. -- Bo Berglund Developer in Sweden _______________________________________________ Openvpn-users mailing list Openvpn-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-users