Exercism: Bash version of the 'Error Handling' exercise.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.8 KiB

3 years ago
  1. # Error Handling
  2. Implement various kinds of error handling and resource management.
  3. An important point of programming is how to handle errors and close
  4. resources even if errors occur.
  5. This exercise requires you to handle various errors. Because error handling
  6. is rather programming language specific you'll have to refer to the tests
  7. for your track to see what's exactly required.
  8. Run the tests with:
  9. ```bash
  10. bats error_handling_test.sh
  11. ```
  12. After the first test(s) pass, continue by commenting out or removing the
  13. `[[ $BATS_RUN_SKIPPED == true ]] || skip`
  14. annotations prepending other tests.
  15. To run all tests, including the ones with `skip` annotations, run:
  16. ```bash
  17. BATS_RUN_SKIPPED=true bats error_handling_test.sh
  18. ```
  19. ## External utilities
  20. `Bash` is a language to write "scripts" -- programs that can call
  21. external tools, such as
  22. [`sed`](https://www.gnu.org/software/sed/),
  23. [`awk`](https://www.gnu.org/software/gawk/),
  24. [`date`](https://www.gnu.org/software/coreutils/manual/html_node/date-invocation.html)
  25. and even programs written in other programming languages,
  26. like [`Python`](https://www.python.org/).
  27. This track does not restrict the usage of these utilities, and as long
  28. as your solution is portable between systems and does not require
  29. installation of third party applications, feel free to use them to solve
  30. the exercise.
  31. For an extra challenge, if you would like to have a better understanding
  32. of the language, try to re-implement the solution in pure `Bash`,
  33. without using any external tools. Note that there are some types of
  34. problems that bash cannot solve, such as performing floating point
  35. arithmetic and manipulating dates: for those, you must call out to an
  36. external tool.
  37. ## Submitting Incomplete Solutions
  38. It's possible to submit an incomplete solution so you can see how others
  39. have completed the exercise.