Permalink
Browse files

MB-100: Make _drop_old_crashdumps work on OS X

The function _drop_old_crashdumps passes negative number to
head -n argument. This is supported only by GNU head and not
others, specifically OS X. Requires bash.

Change-Id: Id14f4618970632f38a21a204dc3f74db19c2e999
Reviewed-on: http://review.couchbase.org/32552
Tested-by: Sriram Melkote <siri@couchbase.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
1 parent 9d922c4 commit e703d8898e6906a2dee104241ff14141f4eaf939 @melkote melkote committed with alk Jan 16, 2014
Showing with 7 additions and 2 deletions.
  1. +7 −2 couchbase-server.sh.in
View
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
#
# Copyright (c) 2010-2011, Couchbase, Inc.
# All rights reserved
@@ -106,7 +106,12 @@ _load_config () {
}
_drop_old_crashdumps () {
- ls -1 erl_crash.dump.* 2>/dev/null | sort | head -n -10 | xargs -- rm -f
+ KEEP="`ls -1 erl_crash.dump.* 2>/dev/null | sort | tail -n 10`"
+ for file in erl_crash.dump.*; do
+ if [[ "$KEEP" != *$file* ]]; then
+ rm -f $file
+ fi
+ done
}

0 comments on commit e703d88

Please sign in to comment.