~charmers/charms/precise/tomcat/trunk

« back to all changes in this revision

Viewing changes to hooks/common.sh

  • Committer: matthew.bruzek at canonical
  • Date: 2014-03-20 20:54:26 UTC
  • Revision ID: matthew.bruzek@canonical.com-20140320205426-dkksq4sva902c9hh
Found a problem in common.sh

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
# $JUJU_UNIT_NAME variable holds the name of the unit.
8
8
 
9
9
add_file_row () {
 
10
  # The first parameter is the file.
10
11
  local file=$1
11
12
  shift
12
13
  if [ -e "${file}" ]; then
 
14
    # Use Extended grep with the invert flag (-v) to find all lines that 
 
15
    # do not start with the unit name (memcached/0).
13
16
    egrep -v "^$1"$'(\t|$)' "${file}" > "${file}.new" || true
14
17
    mv "${file}.new" "${file}"
15
18
  fi
16
 
  shift
17
19
  echo_delimited $'\t' "$@" >> "${file}"
18
20
}
19
21