diff --git a/ex01/README.md b/ex01/README.md index 14faa20..45e7c27 100644 --- a/ex01/README.md +++ b/ex01/README.md @@ -1,64 +1,64 @@ -# Hello World - -The classical introductory exercise. Just say "Hello, World!". - -["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is -the traditional first program for beginning programming in a new language -or environment. - -The objectives are simple: - -- Write a function that returns the string "Hello, World!". -- Run the test suite and make sure that it succeeds. -- Submit your solution and check it at the website. - -If everything goes well, you will be ready to fetch your first real exercise. - -# Welcome to Bash! - -Unlike many other languages here, bash is a bit of a special snowflake. -If you are on a Mac or other unix-y platform, you almost definitely -already have bash. In fact, anything you type into the terminal is -likely going through bash. - -The downside to this is that there isn't much of a development -ecosystem around bash like there is for other languages, and there are -multiple verions of bash that can be frustratingly incompatible. Luckily -we shouldn't hit those differences for these basic examples, and if you -can get the tests to pass on your machine, we are doing great. - -## Installation - -As I said above, if you are on a unix-like OS (Mac OS X, Linux, Solaris, -etc), you probably already have bash. - -## Testing - -As there isn't much of a bash ecosystem, there also isn't really a de -facto leader in the bash testing area. For these examples we are using -[bats](https://github.com/sstephenson/bats). You should be able to -install it from your favorite package manager, on OS X with homebrew -this would look something like this: - -``` -$ brew install bats -==> Downloading -https://github.com/sstephenson/bats/archive/v0.4.0.tar.gz -==> Downloading from -https://codeload.github.com/sstephenson/bats/tar.gz/v0.4.0 -######################################################################## -100.0% -==> ./install.sh /opt/boxen/homebrew/Cellar/bats/0.4.0 -🍺 /opt/boxen/homebrew/Cellar/bats/0.4.0: 10 files, 60K, built in 2 -seconds -``` - -Run the tests with: - - bats whatever_test.sh - -## Source - -This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) - - +# Hello World + +The classical introductory exercise. Just say "Hello, World!". + +["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is +the traditional first program for beginning programming in a new language +or environment. + +The objectives are simple: + +- Write a function that returns the string "Hello, World!". +- Run the test suite and make sure that it succeeds. +- Submit your solution and check it at the website. + +If everything goes well, you will be ready to fetch your first real exercise. + +# Welcome to Bash! + +Unlike many other languages here, bash is a bit of a special snowflake. +If you are on a Mac or other unix-y platform, you almost definitely +already have bash. In fact, anything you type into the terminal is +likely going through bash. + +The downside to this is that there isn't much of a development +ecosystem around bash like there is for other languages, and there are +multiple verions of bash that can be frustratingly incompatible. Luckily +we shouldn't hit those differences for these basic examples, and if you +can get the tests to pass on your machine, we are doing great. + +## Installation + +As I said above, if you are on a unix-like OS (Mac OS X, Linux, Solaris, +etc), you probably already have bash. + +## Testing + +As there isn't much of a bash ecosystem, there also isn't really a de +facto leader in the bash testing area. For these examples we are using +[bats](https://github.com/sstephenson/bats). You should be able to +install it from your favorite package manager, on OS X with homebrew +this would look something like this: + +``` +$ brew install bats +==> Downloading +https://github.com/sstephenson/bats/archive/v0.4.0.tar.gz +==> Downloading from +https://codeload.github.com/sstephenson/bats/tar.gz/v0.4.0 +######################################################################## +100.0% +==> ./install.sh /opt/boxen/homebrew/Cellar/bats/0.4.0 +🍺 /opt/boxen/homebrew/Cellar/bats/0.4.0: 10 files, 60K, built in 2 +seconds +``` + +Run the tests with: + + bats whatever_test.sh + +## Source + +This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) + + diff --git a/ex01/hello_world.sh b/ex01/hello_world.sh new file mode 100644 index 0000000..c5e5720 --- /dev/null +++ b/ex01/hello_world.sh @@ -0,0 +1,7 @@ +#!bash + +if [ $# -eq 0 ]; then + echo "Hello, World!" +else + echo "Hello, ${1}!" +fi diff --git a/ex01/hello_world_test.sh b/ex01/hello_world_test.sh index bc6946b..dbde6b2 100644 --- a/ex01/hello_world_test.sh +++ b/ex01/hello_world_test.sh @@ -1,22 +1,22 @@ -#!/usr/bin/env bats - -@test "When given no name, it should greet the world!" { - run bash hello_world.sh - - [ "$status" -eq 0 ] - [ "$output" = "Hello, World!" ] -} - -@test 'When given "Alice" it should greet Alice!' { - run bash hello_world.sh Alice - - [ "$status" -eq 0 ] - [ "$output" = "Hello, Alice!" ] -} - -@test 'When given "Bob" it should greet Bob!' { - run bash hello_world.sh Bob - - [ "$status" -eq 0 ] - [ "$output" = "Hello, Bob!" ] -} +#!/usr/bin/env bats + +@test "When given no name, it should greet the world!" { + run bash hello_world.sh + + [ "$status" -eq 0 ] + [ "$output" = "Hello, World!" ] +} + +@test 'When given "Alice" it should greet Alice!' { + run bash hello_world.sh Alice + + [ "$status" -eq 0 ] + [ "$output" = "Hello, Alice!" ] +} + +@test 'When given "Bob" it should greet Bob!' { + run bash hello_world.sh Bob + + [ "$status" -eq 0 ] + [ "$output" = "Hello, Bob!" ] +} diff --git a/ex02/ex02.sh b/ex02/ex02.sh new file mode 100644 index 0000000..b5e8a8d --- /dev/null +++ b/ex02/ex02.sh @@ -0,0 +1,5 @@ +#!bash + +for i in ${@}; do + ls -R | grep ${i} || echo "the searched PATH is unexisting" +done