4 ms·
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
by Darfk 8mo ago
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.
- james_marks 8mo agoYep. First thing I do for this kind thing is make a preview=true flag so I don’t accidentally run destructive actions.
- mycall 8mo agoNow I like that idea as an environment variable that takes precedence over the command parameters.
- Joker_vD 8mo agoif [ -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.
- digiown 8mo agoset -o noclobber
- deleted 8mo ago[deleted]