Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In case you're interested, I have adopted a pattern that works for me in bash (I don't use zsh so caveat shellator)

  N=${N:-}  # if you use (-u)
  $N rm ./whatever
and then you can exercise the script via

  N=echo ./something-dangerous
but without the N defined it will run it as expected. More nuanced commands (e.g. rsync --delete --dry-run which will provide a lot more detail about what it thinks it is going to do) could be written as `rsync --delete ${N:+--dry-run}` type deal


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: