andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.53k stars 177 forks source link

[Question] How to correctly answer "Proceed? (y/n)" when using trash-empty in script? #333

Open sudoshindo opened 5 months ago

sudoshindo commented 5 months ago

I have been testing the behavior of trash-empty because I want to use it in a script.

I've found that doing echo 'n' | trash-empty or trash-empty <<< n still continues to empty the trash even though answering the prompt with n manually actually cancels the action.

I know that answering no/n is not something anyone would do in a script, but it bothers me that it doesn't behave consistently.

sudoshindo commented 5 months ago

I did some code reading, I found that the -f flag found here is not included in the man page for trash-empty.

I often check a command's man page first. If the man page exists, I assume that it would show me the complete flags.

It would not have crossed my mind that I need to check -h or --help because it has completely different output from man command.

sudoshindo commented 3 months ago

No manpage changes?

I found an answer to my question, but maybe you can make this specific information easier to find.

sudoshindo commented 3 months ago

Additional suggestion:

Also add an -f example to the README.

andreafrancia commented 3 months ago

Ok, we can reopen this.

If you want to be solved quickly you can change man pages by yourself and send a pull request, the file is man/man1/trash-empty.1. If this is the case please include in the pull request form a screenshot of the man page rendering the part you've added. You can render the man page without installing trashcli using man man/man1/trash-empty.1.

And you can add an -f example to README.

These documentation PR are very welcome.