News for hackers. Stuff that matters.
Re:Command Line Interface Guidelines by danstewart_ on Tuesday February 06, 2024 @03:35PM (#39280199)
I tend to go the opposite way and have the default behaviour not actually make any changes and require passing `--commit` to actually do something.

I feel it’s safer for scripts that have irreversible (or difficult to reverse) actions.

Re:Command Line Interface Guidelines by enriquto on Tuesday February 06, 2024 @04:28PM (#39280898)
Even safer: your program does never perform any actual deed. It just prints commands that you can run afterwards, using an external program, ideally a shell. This has the advantage of allowing the user to edit all the actions one by one.

Instead of

    myprog           # see what would happen
    myprog --commit  # alright, do it

You do

    myprog           # see what would happen
    myprog | sh      # alright, do it

But if you want to change something:

    myprog > x
    vi x
    cat x | sh

And if you just want to run everything in parallel:

    myprog | parallel -j 16