After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 775062 - sysprof-cli arguments cause files to be overwritten by mistake
sysprof-cli arguments cause files to be overwritten by mistake
Status: RESOLVED FIXED
Product: sysprof
Classification: Other
Component: general
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: Sysprof maintainer(s)
Sysprof maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-11-25 02:00 UTC by Hubert Figuiere (:hub)
Modified: 2016-11-26 23:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (1.91 KB, patch)
2016-11-26 15:08 UTC, Hubert Figuiere (:hub)
committed Details | Review

Description Hubert Figuiere (:hub) 2016-11-25 02:00:21 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.
Comment 1 Christian Hergert 2016-11-26 00:57:42 UTC
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.
Comment 2 Hubert Figuiere (:hub) 2016-11-26 15:08:56 UTC
Created attachment 340801 [details] [review]
Proposed patch

This patch implement -f|--force and make overwrite fail by default.
Comment 3 Hubert Figuiere (:hub) 2016-11-26 15:25:31 UTC
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.
Comment 4 Christian Hergert 2016-11-26 22:59:34 UTC
Review of attachment 340801 [details] [review]:

LGTM, Thanks!
Comment 5 Hubert Figuiere (:hub) 2016-11-26 23:21:59 UTC
pushed to master

87289e04212b2cde72ca53f7ce29c6a3b43322d9
Comment 6 Hubert Figuiere (:hub) 2016-11-26 23:25:44 UTC
Closing since I think the solution is good enough.