News for hackers. Stuff that matters.
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)