News for hackers. Stuff that matters.
Re:In Praise Of –Dry-Run by mycall on Saturday January 31, 2026 @08:56PM (#46842895)
I like the opposite too, -commit or -execute as it is assumed running it with defaults is immutable as the dry run, simplifying validation complexity and making the go live explicit.
Re:In Praise Of –Dry-Run by spike021 on Saturday January 31, 2026 @11:45PM (#46843684)
There was a tool I used some time ago that required typing in a word or phrase to acknowledge that you know it's doing the run for real.

Pros and cons to each but I did like that because it was much more difficult to fat finger or absentmindedly use the wrong parameter.

Re:In Praise Of –Dry-Run by esafak on Sunday February 01, 2026 @05:13PM (#46849920)
Github will do that when you delete a repo.
Re:In Praise Of –Dry-Run by Twirrim on Saturday January 31, 2026 @09:20PM (#46843017)
I've biased towards this heavily in the last 8 or so years now.

I've yet to have anyone mistakenly modify anything when they need to pass --commit, when I've repeatedly had people repeatedly accidentally modify stuff because they forgot --dry-run.

Re:In Praise Of –Dry-Run by IgorPartola on Saturday January 31, 2026 @09:52PM (#46843184)
I wouldn’t want most things to work this way:

    $ rm file.bin
    $ rm —-commit file.bin
    $ cat foo.txt > bar.txt
    $ cat foo.txt | tee —-write-for-real bar.txt
    $ cp balm.mp3 pow.mp3
    $ cp —-i-mean-it balm.mp3 pow.mp3
There is a time and a place for it but it should not be the majority of use cases.
Re:In Praise Of –Dry-Run by Darfk on Saturday January 31, 2026 @10:05PM (#46843256)
Totally agree it shouldn't be for basic tools; but if I'm ever developing a script that performs any kind of logic before reaching out to a DB or vendor API and modifies 100k user records, creating a flag to just verify the sanity of the logic is a necessity.
Re:In Praise Of –Dry-Run by Joker_vD on Saturday January 31, 2026 @10:13PM (#46843299)

    if [ -n "$DRY_RUN" ] ; then
        alias rm='echo rm'
        alias cp='echo cp'
    fi
Of course, output redirects will still overwrite the files, since the shell does it and IIRC this behaviour can't be changed.
Re:In Praise Of –Dry-Run by digiown on Saturday January 31, 2026 @10:22PM (#46843328)
set -o noclobber
Re:In Praise Of –Dry-Run by james_marks on Saturday January 31, 2026 @10:11PM (#46843287)
Yep. First thing I do for this kind thing is make a preview=true flag so I don’t accidentally run destructive actions.
Re:In Praise Of –Dry-Run by mycall on Wednesday February 04, 2026 @07:09PM (#46893811)
Now I like that idea as an environment variable that takes precedence over the command parameters.
Re:In Praise Of –Dry-Run by digiown on Saturday January 31, 2026 @10:20PM (#46843319)
For most of these local data manipulation type of commands, I'd rather just have them behave dangerously, and rely on filesystems snapshots to rollback when needed. With modern filesystems like zfs or btrfs, you can take a full snapshot every minute and keep it for a while to negate the damage done by almost all of these scripts. They double as a backup solution too.
Re:In Praise Of –Dry-Run by hdjrudni on Saturday January 31, 2026 @10:12PM (#46843297)
Even in those basic examples, it probably would be useful. `cp` to a blank file? No problem. `cp` over an existing file? Yeah, I want to be warned.

`rm` a single file? Fine. `rm /`? Maybe block that one.

Re:In Praise Of –Dry-Run by Izkata on Sunday February 01, 2026 @02:23AM (#46844246)
That last one would error without doing anything anyway because it's not recursive.
Re:In Praise Of –Dry-Run by ronjakoi on Sunday February 01, 2026 @12:58AM (#46844000)
I used to have alias rm='rm -i' for a few years to be careful, but I took it out once I realised that I had just begun adding -f all the time
Re:In Praise Of –Dry-Run by wonger_ on Sunday February 01, 2026 @07:03AM (#46845604)
See also rm -I (capital i), which only prompts when deleting >3 files or directories
Re:In Praise Of –Dry-Run by Mawr on Sunday February 01, 2026 @10:33AM (#46846856)
Yeah, but that's because it's implemented poorly. It literally asks you to confirm deletion of each file individually, even for thousands of files.

What it should do is generate a user-friendly overview of what's to be deleted, by grouping files together by some criteria, e.g. by directory, so you'd only need to confirm a few times regardless of how many files you want to delete.

Re:In Praise Of –Dry-Run by Mawr on Sunday February 01, 2026 @10:30AM (#46846837)
Uhuh:

    $ rm -rf /

    rm: it is dangerous to operate recursively on '/'
    rm: use --no-preserve-root to override this failsafe
Re:In Praise Of –Dry-Run by account42 on Monday February 02, 2026 @09:00AM (#46856122)
That's a special case that is a) easy to call accidentally from a script when variables end up being unset and b) almost never a sensible thing to do.
Re:In Praise Of –Dry-Run by __turbobrew__ on Sunday February 01, 2026 @02:26AM (#46844262)
—dry-run should default to true
Re:In Praise Of –Dry-Run by fainpul on Sunday February 01, 2026 @07:47AM (#46845869)
Re:In Praise Of –Dry-Run by xyse53 on Saturday January 31, 2026 @09:23PM (#46843025)
Yeah I'm more of a `--wet-run` `-w` fan myself. But it does depend on how serious/annoying the opposite is.
Re:In Praise Of –Dry-Run by aqme28 on Saturday January 31, 2026 @09:30PM (#46843060)
I've done that, but I hate the term "wet run."

I use "live run" now, which I think gets the point across without being sort of uncomfortable.

Re:In Praise Of –Dry-Run by Quekid5 on Saturday January 31, 2026 @10:36PM (#46843378)
Moist run is the way.
Re:In Praise Of –Dry-Run by IgorPartola on Saturday January 31, 2026 @09:54PM (#46843190)
--with-danger

--make-it-so

--do-the-thing

--go-nuts

--safety-off

So many fun options.

Re:In Praise Of –Dry-Run by Darfk on Saturday January 31, 2026 @10:10PM (#46843286)
I'm a fan of --safety-off. It gives off a 'aim away from face' or 'mishandle me and I'll blow a chunk out of your DB' vibe.
Re:In Praise Of –Dry-Run by JsonCameron on Saturday January 31, 2026 @10:43PM (#46843416)
I've done a few --execute --i-know-what-im-doing for some more dangerous scripts
Re:In Praise Of –Dry-Run by altairprime on Saturday January 31, 2026 @11:29PM (#46843624)
May I recommend --I-take-responsibility-for-the-outcome-of-proceeding and require a capital I?
Re:In Praise Of –Dry-Run by altairprime on Saturday January 31, 2026 @11:28PM (#46843620)
--commit is solid too
Re:In Praise Of –Dry-Run by torstenvl on Sunday February 01, 2026 @12:32AM (#46843907)
It's in the UI not the command line, but I like Chromium's thisisunsafe
Re:In Praise Of –Dry-Run by tetha on Sunday February 01, 2026 @03:51AM (#46844621)
I find it important to include system information in here as well, so just copy-pasting an invocation from system A to system B does not run.

For example, our database restore script has a parameter `--yes-delete-all-data-in` and it needs to be parametrized with the PostgreSQL cluster name. So a command with `--yes-delete-all-data-in=pg-accounting` works on exactly one system and not on other systems.

Re:In Praise Of –Dry-Run by bregma on Sunday February 01, 2026 @06:20AM (#46845390)

    --moisten
Re:In Praise Of –Dry-Run by lazide on Saturday January 31, 2026 @11:34PM (#46843643)
Just don’t randomly mix and match the approaches or you are in for a bad time.
Re:In Praise Of –Dry-Run by torstenvl on Sunday February 01, 2026 @12:30AM (#46843892)
I have a parallel directory deduper that uses hard links and adopted this pattern exactly.

By default it'll only tell you which files are identical between the two parallel directory structures.

If you want it to actually replace the files with hard links, you have to use the --execute flag.

Re:In Praise Of –Dry-Run by sigwinch on Sunday February 01, 2026 @07:56AM (#46845909)
rmlint will only run a previous dry-run snapshot.
Re:In Praise Of –Dry-Run by inglor_cz on Sunday February 01, 2026 @07:53AM (#46845891)
This is something I learnt here.

My latest script which deletes the entire content of a downloaded Sharepoint (locally only) and the relevant MS365 account from the computer runs by default in a read-only mode. You have to run it with an explicit flag to allow for changes.

Also, before it actually deletes the account, you need to explicitly type DELETE-ACCOUNT in order to confirm that this is indeed your intent.

So far, nobody managed to screw up, even in heated situations at client's place.

Re:In Praise Of –Dry-Run by rglynn on Monday February 02, 2026 @03:10AM (#46853631)
Agree with this tactic, very useful when working in a team. I use a --dry-run=false approach.
Re:In Praise Of –Dry-Run by michaelcampbell on Monday February 02, 2026 @08:46AM (#46855982)
I have a few shell scripts using `getopts` that have a `-!` flag to make it go; the default is dry-run.

And it's pretty nice. The downside is if you get used to that behavior in things that don't have it the consequences can be bad. (Like the common `alias rm='rm -i'`. No, that's just a trap; don't do it.)