Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show correct information and fix error caused by dash on printf in clientStat.sh #1661

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

astroganga
Copy link

@astroganga astroganga commented Nov 30, 2022

At line 53 of clientStat.sh there is a printf that starts with minus sign

53 printf "- %s\n" "${array[9]}"

When pivpn clients command is executed the minus sign is interpreted as an option and the script fails by not printing the connection time.

I fixed the issue adding -- before the format string to disarm the minus sign.

53 printf -- "- %s\n" "${array[9]}"

Hope this helps.
Thanks
Bye.

@coolapso
Copy link
Member

hi, ty for the PR .. please read and change the target branch: https://github.com/pivpn/pivpn#pull-requests

@astroganga astroganga changed the base branch from master to test November 30, 2022 21:59
Copy link
Member

@coolapso coolapso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again thanks a lot for your PR, after a proper review, please check my comments regarding the code itself.

Also please amend your commit message to be according to the commit rules.

In this situation the way I would do it is:

  • git reset HEAD~1
  • make the suggested code changes
  • git commit

The header of the commit should be: fix(scripts): fix clientstat.sh
The commit body should be (for example): show correct information and fix error caused by dash on printf

should look something like:

fix(scripts): clientstat.sh

show correct information and fix error caused by dash on printf
  • git push origin master --force

Please note the suggestion is just one way of doing it, feel free to use any method that feels better for you.

scripts/openvpn/clientStat.sh Show resolved Hide resolved
@coolapso
Copy link
Member

hmm crap ... don't think changing from stable to test will change anything, it seems the openvpn-status.log saves data based on some regional settings which affects the position of the array where the data ends up =/ this kind of "parsing" is always messy =/

then I say it might be better to just remove the dash, and some day if i have the time I might try to find a better way to parse the log file.

@astroganga
Copy link
Author

astroganga commented Nov 30, 2022

Ok. If you agree I will adjust the fix removing the dash on line 53:

printf "%s\n" "${array[9]}"

without touching array order. If some are empty I don't think will be an issue and at the same time we will not lose information on other regional settings.

I will do it tomorrow as it is too late for me now.
Thanks

@coolapso
Copy link
Member

coolapso commented Dec 1, 2022

yeah its fine, just remove the dash.

On my case (using aws ec2 instnace), it was actually returning meaningless data.

show correct information and fix error caused by dash on printf
@astroganga astroganga changed the title Fixed printf that starts with minus sign in clientStat.sh Show correct information and fix error caused by dash on printf in clientStat.sh Dec 1, 2022
@coolapso coolapso merged commit 1e1c8fa into pivpn:test Dec 1, 2022
@coolapso
Copy link
Member

coolapso commented Dec 1, 2022

Done, thanks a lot :D

@coolapso
Copy link
Member

coolapso commented Dec 1, 2022

🎉 This PR is included in version 4.1.6-test.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@coolapso
Copy link
Member

🎉 This PR is included in version 4.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants