blob: 622e56780f1e92dfb13595dd5b9b9255b7dd3675 [file] [log] [blame]
Tom Cherryd8ea11f2019-10-30 13:51:03 -07001#! /system/bin/sh
2
3# This is primarily meant to be used by logpersist. This script is run as an init service, which
4# first reads the 'last' logcat to persistent storage with `-L` then run logcat again without
5# `-L` to read the current logcat buffers to persistent storage.
6
7has_last="false"
8for arg in "$@"; do
9 if [ "$arg" == "-L" -o "$arg" == "--last" ]; then
10 has_last="true"
11 fi
12done
13
14if [ "$has_last" == "true" ]; then
15 logcat "$@"
16fi
17
18args_without_last=()
19for arg in "$@"; do
20 if [ "$arg" != "-L" -a "$arg" != "--last" ]; then
21 ARGS+=("$arg")
22 fi
23done
24
25exec logcat "${ARGS[@]}"