diff --git a/tests/test_get_commands.sh b/tests/test_get_commands.sh new file mode 100644 index 0000000..57dc45c --- /dev/null +++ b/tests/test_get_commands.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +setup() { + source ../zk +} + +test_get_command_returns_list_for_substring() { + expected="list" + + for arg in l li lis list; do + result="$(get_command "$arg")" + assert_equals "$expected" "$result" + done +} diff --git a/zk b/zk index 580ce67..25409bc 100755 --- a/zk +++ b/zk @@ -1,5 +1,15 @@ #!/bin/sh +COMMANDS='list' + +get_command() { + for c in $COMMANDS; do + if echo "$c" | grep "$1" >/dev/null; then + echo "$c" + fi + done +} + main() { echo "Hello, world" }