[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Revisiting Error handling (errexit)
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: Revisiting Error handling (errexit) |
Date: |
Fri, 8 Jul 2022 12:28:06 +0200 |
On Fri, Jul 8, 2022, 12:23 Oğuz <oguzismailuysal@gmail.com> wrote:
> 8 Temmuz 2022 Cuma tarihinde Yair Lenga <yair.lenga@gmail.com> yazdı:
> >
> > Practical Example - real life. A job has to copy 3 critical data files.
> It
> > then sends notification via email (non-critical).
> >
> > #! /bin/bash
> > set -o errfail
> > function copy-files {
> > # ALL files are critical, script will not cont
> > cp /new/file1 /production/path/
> > cp /new/file2 /production/path/
> > # Use the files for something - e.g., count the lines.
> > important-job /production/path/file1 /production/path/file2
> >
> > ls -l /production/path | mail -s "all-good" notify@company.com ||
> > true # Not critical
>
small side note there, a || true is big slow imho
> }
> >
> > if copy-files ; then
> > more-critical-jobs
> > echo "ALL GOOD"
> > else
> > mail -s "PROBLEM" norify@company.com < /dev/null
> > fi
> >
> > What is the difference ? consider the case where /new/file1 does not
> > exists, which is critical error.
> > * Without errfail, an error message will be sent to script stderr, but
> the
> > script will continue to copy the 2nd file, and to perform the
> > important-job, even though the data is not ready.
>
>
> How is this any better than doing `cp ... && cp ... && important-job ...'?
>
>
> --
> Oğuz
>
- Re: Revisiting Error handling (errexit), (continued)
- Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/04
- Re: Revisiting Error handling (errexit), Greg Wooledge, 2022/07/04
- Re: Revisiting Error handling (errexit), Lawrence Velázquez, 2022/07/04
- Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/04
- Re: Revisiting Error handling (errexit), Lawrence Velázquez, 2022/07/04
- Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/05
- Re: Revisiting Error handling (errexit), Lawrence Velázquez, 2022/07/05
- Re: Revisiting Error handling (errexit), David, 2022/07/04
Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/08
Re: Revisiting Error handling (errexit), Kerin Millar, 2022/07/08
Re: Revisiting Error handling (errexit), Yair Lenga, 2022/07/08
Re: Revisiting Error handling (errexit), Greg Wooledge, 2022/07/08
Re: Revisiting Error handling (errexit), Martin D Kealey, 2022/07/08