Checksyntaxwritefile
Changed checkSyntax to no longer write to files. Also, created separation between checkSyntax & checkSyntaxFile, as well as added more test cases & python files to ensure syntax checking is going well.
Okay, I have added changes, however I apologise I did not end up using stdin. The main reason was that I also had to add some extra functionality to make sure that command line special characters do not cause an issue. I will try to explain below:
I was thinking about your example, and your suggestion of stdin was to stop the program thinking quotation marks within the user's code are meant to couple together with the quotation marks from the compileCommand for the python code right? So, with your example, where you did:
x=5#'
That causes the quotation mark to create issues when inserted into:
${pythonPath} -c "compile('${formattedCode}', '', 'exec');"
Because now it thinks that the ' mark after compile is meant to meet with the ' mark inside the code. So, just in case, I added a test case where it uses every single special character to see which ones would be a problem:
x=5#'\"_-~!@$%&^*()=+,<.>/?{}[]\\|;:
However, while using this one, I noticed a second issue. The |, <, >, ^ and & characters are all read by the terminal and used for their own things, such as | being the pipe function, and thus if the code that the user is sending in has a singular | anywhere E.g:
x = "hi | hi2"
The command line would think we are piping x = "hi into hi2" which would also cause issues.
So, instead, I create a custom function which essentially does the formatting check for you by adding in its own \ and ^ character to make sure everything is escaped properly. I tested it with two very messy examples to make sure it is working, and I got it to work.
However, I do realise my solution is kinda scuffed and far from the cleanest, so could you perhaps add a few test cases you can think of to make sure nothing goes wrong? I am very sorry for doing a solution this scuffed, I could not think of another solution for the command line special character problem.