#!/bin/bash

# Lowercase.bash
# Wed Feb 15 13:12:46 PST 2012
# Chieh Cheng
# http://www.CynosureX.com/

# GNU General Public License (GPL) Version 2, June 1991

  scriptDir=`dirname "$0"`
  scriptName=`basename "$0"`

function process ()
{
  string="$1"
  echo "${string,,}"
}

function usage ()
{
  echo "  Usage:   \"${scriptName}\" \"string\""
  echo
  echo "             Use a '-' in place of the string to read"
  echo "             from standard input (pipe)."
}

  if [ $# -eq 1 ]
  then
    string="$1"

    if [ "${string}" = "-" ]
    then
      while read line
      do
        process "${line}"
      done
    else
      process "${string}"
    fi
  else
    usage
  fi
