Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 64 additions & 64 deletions ex01/README.md
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions ex01/hello_world.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!bash

if [ $# -eq 0 ]; then
echo "Hello, World!"
else
echo "Hello, ${1}!"
fi
44 changes: 22 additions & 22 deletions ex01/hello_world_test.sh
Original file line number Diff line number Diff line change
@@ -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!" ]
}