GNOME Bugzilla – Bug 775062
sysprof-cli arguments cause files to be overwritten by mistake
Last modified: 2016-11-26 23:25:44 UTC
`sysprof-cli ./src/abiword` caused ./src/abiword to be overwritten. `sysprof-cli -c ./src/abiword ~/mytestfile.rtf` caused ~/mytestfile.rtf to be overwritten. Here is what changes could be made to improve it: 1. ask about overwriting the file. Even more if it doesn't look like a sysprof output. 2. change the command line arguments. For example explicit "-o output-file.log", having "-c" work like --args in gdb. I'm not sure how bad it would be to implement #2 (ie what it would break) Good thing I had a backup of that test file.
The command line arguments have existed before the modernization of sysprof, so I'd like to keep them the same so we don't break years of peoples workflow. However, maybe we should add a -f|--force for overwriting files? Also, I don't mind doing something like -- to allow argv without shell parsing.
Created attachment 340801 [details] [review] Proposed patch This patch implement -f|--force and make overwrite fail by default.
I'm not sure we can do -- command_args since we expect the filename as a leftover argument already in the parser and -- is dealt as "give all the left overs in the argv". We would need to do something like option 2 above, ie have the filename passed as value of an option.
Review of attachment 340801 [details] [review]: LGTM, Thanks!
pushed to master 87289e04212b2cde72ca53f7ce29c6a3b43322d9
Closing since I think the solution is good enough.