11 ms·
Not so long ago I used ChatGPT to help me come up with a command to delete files that were older than 7 days. Fortunately I checked the result before copy pas
by maaaaattttt 3y ago
Not so long ago I used ChatGPT to help me come up with a command to delete files that were older than 7 days.
Fortunately I checked the result before copy pasting what GPT told me as it would have deleted any file older than 7 days on the machine. I know it was “my fault” to begin with as I didn’t explicitly specify “in the current directory” or “in a given directory”. But I can see how making such a (very nice nonetheless) tool part of one’s daily routine could quickly lead to damaging outcomes.
- vlowrian 3y agoFor any shell command where a minor mistake has the potential of ruining your day, take a look at “try”, which will allow you to inspect the effects before running it against a live system: https://github.com/binpash/try https://github.com/binpash/try
- maaaaattttt 3y agoThat's a great tool! Hope OP's sees this. If the default would be to use "try" when using shelly and I just had to "commit [Y/n]" at the end, then I would seriously consider using it. One could do something like `shelly "my description" --force` to bypass the "try" usage.
- philipwhiuk 3y ago> Please note that try is a prototype and not a full sandbox, and should not be used to execute commands that you don't already trust on your system, (i.e. network calls are all allowed)
- vlowrian 3y agoTrue, ‘try’ won’t make reading and understanding a command obsolete, but it’s a great tool to prevent accidental deletion of important files, like OP described.
- samstave 3y agoI was taught that Try was to be sure your command was well formed, if its a complex command with some regex for example... Though I have not used it much over the years, as I havent had to do much personal regex for a long while.
- WhackyIdeas 3y agoNo, but I done something more stupid. I had it help me write a command to delete Woocommerce/Wordpress users from my site which were older than 1 year and who had never ordered before. It deleted tens of thousands of active users who had placed orders. I had a backup which was only a couple of hours old, thank the lord. Lesson learned.