Sha256: ade4645b07819f41b8e22d92446d9a15b0b1edf43e26bce3c3e01ba7f770cb7d

Contents?: true

Size: 1.3 KB

Versions: 60

Compression:

Stored size: 1.3 KB

Contents

#!/bin/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

60 entries across 60 versions & 1 rubygems

Version Path
trackler-2.2.1.82 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.81 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.80 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.79 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.78 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.77 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.76 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.75 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.74 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.73 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.72 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.71 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.70 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.69 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.68 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.67 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.66 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.65 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.64 tracks/bash/exercises/bob/example.sh
trackler-2.2.1.63 tracks/bash/exercises/bob/example.sh