Sha256: 05cd863f94e33cecab7fa7b3b8bb265b3dd2980e2096cbd454573eff0230cde9

Contents?: true

Size: 1.31 KB

Versions: 96

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env bash

# Exit on error. Append || true if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch error even if it's not in after the last pipe.
set -o pipefail
# Turn on traces, useful while debugging but commented out by default
# set -o xtrace

#__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
#__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
#__base="$(basename ${__file} .sh)"

# print argument and exit
function say() {
  local mesg=${1}
  echo "${mesg}"
  exit 0
}

if [[ $# -eq 0 ]]; then
  say "Fine. Be that way!"
fi

# Get what Bob says.
# %b interprets escapted characters (like '\n' for newline)
input="$(printf %b "${1}")"

# Remove space characters
input="${input//[[:space:]]/}"
#input="${input//$(printf '\u00a0')}" # [[:space:]] doesn't match \u00a0 on Linux

# Is there silence?
if [[ "${input}" == "" ]]; then
  say "Fine. Be that way!"
fi

# Is there shouting (capital letter and no lowercase letters)
if [[ "$input" == *[[:upper:]]* ]] && [[ "$input" != *[[:lower:]]* ]]; then
  say "Whoa, chill out!"
fi

# Is it a question? (last character is a '?')
if [[ "${input: -1}" == "?" ]]; then
  say "Sure."
fi

# Is it a regular statement ?
echo "Whatever."

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.97 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.96 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.95 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.94 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.93 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.92 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.91 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.90 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.89 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.88 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.87 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.86 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.85 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.84 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.83 tracks/bash/exercises/bob/example.sh