Exercism: Bash version of the 'two-fer' 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.

72 lines
2.1 KiB

3 years ago
  1. # Two Fer
  2. `Two-fer` or `2-fer` is short for two for one. One for you and one for me.
  3. Given a name, return a string with the message:
  4. ```text
  5. One for name, one for me.
  6. ```
  7. Where "name" is the given name.
  8. However, if the name is missing, return the string:
  9. ```text
  10. One for you, one for me.
  11. ```
  12. Here are some examples:
  13. |Name |String to return
  14. |:-------|:------------------
  15. |Alice |One for Alice, one for me.
  16. |Bob |One for Bob, one for me.
  17. | |One for you, one for me.
  18. |Zaphod |One for Zaphod, one for me.
  19. Run the tests with:
  20. ```bash
  21. bats two_fer_test.sh
  22. ```
  23. After the first test(s) pass, continue by commenting out or removing the
  24. `[[ $BATS_RUN_SKIPPED == true ]] || skip`
  25. annotations prepending other tests.
  26. To run all tests, including the ones with `skip` annotations, run:
  27. ```bash
  28. BATS_RUN_SKIPPED=true bats two_fer_test.sh
  29. ```
  30. ## Source
  31. [https://github.com/exercism/problem-specifications/issues/757](https://github.com/exercism/problem-specifications/issues/757)
  32. ## External utilities
  33. `Bash` is a language to write "scripts" -- programs that can call
  34. external tools, such as
  35. [`sed`](https://www.gnu.org/software/sed/),
  36. [`awk`](https://www.gnu.org/software/gawk/),
  37. [`date`](https://www.gnu.org/software/coreutils/manual/html_node/date-invocation.html)
  38. and even programs written in other programming languages,
  39. like [`Python`](https://www.python.org/).
  40. This track does not restrict the usage of these utilities, and as long
  41. as your solution is portable between systems and does not require
  42. installation of third party applications, feel free to use them to solve
  43. the exercise.
  44. For an extra challenge, if you would like to have a better understanding
  45. of the language, try to re-implement the solution in pure `Bash`,
  46. without using any external tools. Note that there are some types of
  47. problems that bash cannot solve, such as performing floating point
  48. arithmetic and manipulating dates: for those, you must call out to an
  49. external tool.
  50. ## Submitting Incomplete Solutions
  51. It's possible to submit an incomplete solution so you can see how others
  52. have completed the exercise.