For example I have a function that appends to a file a few lines. But if something else fails in the script I wouldn’t want to fix it and execute it again, and then have those lines duplicated.

@thann
mod
admin
link
fedilink
44M

FWIW, not having side-effects from being ran twice is called “idempotency

@ajr@lemmy.ml
creator
link
fedilink
24M

I’ve thought of creating a json where I indicate what parts have been executed successfully.

azron
link
fedilink
14M

Json or some other indicator of status. If statements and flat files you can easily delete to reset state. You have the right notion as to how to do it. Some sort of indicator that something has run. Possibly consider having an over arching concept of a run so you clearly status like run1.json or /run1/state.statefile

Ask specific questions about how to code something in sh, bash, zsh, etc

General bash discussion on lemmy.ml

Create Post From:
lemmy.ml

  • 0 users online
  • 2 users / day
  • 2 users / week
  • 2 users / month
  • 5 users / 6 months
  • 17 subscribers
  • 9 Posts
  • 17 Comments
  • Modlog