Jul-22-2018, 10:11 PM
this script i have in file /usr/local/bin/cpp (the parent is in my PATH) which has two errors in it:
why would it run sometimes? if Python pre-parse everything, first, then shouldn't it always fail with a syntax error for the missing closing parenthesis?
why would it not output an error message when it failed? or could it be doing os.execvp with garbage? any idea why i would get that error message under strace?
this was an old script. i had intended to use Exception back then. i am changing it to OSError.
fixed!
i renamed the command to cppv
now the file /usr/local/bin/cppv looks like:
but i still wonder why it sometimes worked.
and i also still wonder why it would not output a message when it failed.
and why it decided to output the message when i was about to discover why it didn't.
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from __future__ import print_function import os,sys os.execvp('cp',['cp','-pv']+sys.argv[1:]) raise Exceptiom('execvp failed to execute cp'would sometimes work (the file would be copied) and sometimes fail (the file would not be copied). every time it would fail there were no messages output. every time it would work it would always output the message from the cp command it was running. before i saw the two errors i tried to run it under strace to have something to check on about the original in case i too quickly changed the file. under strace it did give me a syntax error message and then i saw both errors.
why would it run sometimes? if Python pre-parse everything, first, then shouldn't it always fail with a syntax error for the missing closing parenthesis?
why would it not output an error message when it failed? or could it be doing os.execvp with garbage? any idea why i would get that error message under strace?
this was an old script. i had intended to use Exception back then. i am changing it to OSError.
fixed!
i renamed the command to cppv
now the file /usr/local/bin/cppv looks like:
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from __future__ import print_function import os,sys os.execvp('cp',['cp','-pv']+sys.argv[1:]) raise OSError('execvp failed to execute cp')
but i still wonder why it sometimes worked.
and i also still wonder why it would not output a message when it failed.
and why it decided to output the message when i was about to discover why it didn't.