Randomly changes the value of parameters passed between Bash functions
This seems like an issue with multi-threaded programming of some kind where one thread is acting on another thread’s data. I’m not sure if the issue would be with the terminal windows on the local host (MacOS) or the remote Amazon Linux operating system.
I’m running a terminal window to connect to an Amazon EC2 Linux host to run the scripts in this GitHub repository.
I recently started adding scripts to deploy networks.
I have a common function that calculates and adds a parameter to a comma separated list of values. I pass that list into a function that is supposed to deploy a CloudFormation template for a network stack.
What happens is that if I open a second terminal window, the parameter list will randomly show up as “1” instead of the correct parameter list. Since my code has not changed at all I know this inconsistency is something outside my code. I have somehow pinpointed it to having two terminal windows open. When I close the second window the error goes away.
I have a function that validates that a value exists. If it doesn’t it returns “1” and the program exits. It could be that somehow when it checks for the value, the value is null and that function returns one giving me this very confusing result.
However, there is no way my code is passing an empty value to that function. Additionally, the problem does not occur every time I have a second terminal window open. It is random. That means there’s something randomly executing in the background causing this (I think).
Well, at least I have a work around…
If you liked this story please clap and follow:
Medium: Teri Radichel or Email List: Teri Radichel
Twitter: @teriradichel or @2ndSightLab
Requests services via LinkedIn: Teri Radichel or IANS Research
© 2nd Sight Lab 2022
Need Cloud Security Training? 2nd Sight Lab Cloud Security Training
Cybersecurity & Cloud Security Resources by Teri Radichel: Cybersecurity and Cloud security classes, articles, white papers, presentations, and podcasts