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

Remove leading zeros #954

Merged
merged 3 commits into from
Jan 21, 2022
Merged

Remove leading zeros #954

merged 3 commits into from
Jan 21, 2022

Conversation

EricClaeys
Copy link
Collaborator

Bash treats numbers with a leading 0 as octal, so if we try to convert the string "09" to an integer it'll complain that "9" isn't an octal number. So, don't pass numbers to saveImage.sh with leading zero's. If saveImage.sh or another script want a fixed length number, it can create it in the desired format. For example, "9" can be converted to "09".

This bug breaks anyone with dark images taken when the sensor is either 8 or 9 degrees (which happened).

When converting a string to a number, if the string begins with a 0, it's treated as an octal number.  Unfortunately, if the THIS_TEMPERATURE variable is "09" that gives an error when converted to integer since 9 is not a legal octal number.
I couldn't find anyway around this.
I will also change capture.cpp to not add a leading 0, but it's possible a user script stores numbers with a leading 0 in tmp/temperature.txt.
Also, don't specify a number length, because without a leading zero we may get " 9" with a leading space, which is even worse!
@EricClaeys EricClaeys added the bug Needs software change label Jan 21, 2022
Copy link
Collaborator

@AndreasLMeg AndreasLMeg left a comment

Choose a reason for hiding this comment

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

@EricClaeys: looks fine for me.

@EricClaeys EricClaeys merged commit a7c91da into master Jan 21, 2022
@EricClaeys
Copy link
Collaborator Author

@AndreasLMeg Do a man bash > /tmp/bash then edit the file and look for ##. Somewhere there it describes the parentheses syntax I used. I didn't know about that until I looked it up.

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

Successfully merging this pull request may close these issues.

2 participants