Tom Cherry | d8ea11f | 2019-10-30 13:51:03 -0700 | [diff] [blame^] | 1 | #! /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 | |
| 7 | has_last="false" |
| 8 | for arg in "$@"; do |
| 9 | if [ "$arg" == "-L" -o "$arg" == "--last" ]; then |
| 10 | has_last="true" |
| 11 | fi |
| 12 | done |
| 13 | |
| 14 | if [ "$has_last" == "true" ]; then |
| 15 | logcat "$@" |
| 16 | fi |
| 17 | |
| 18 | args_without_last=() |
| 19 | for arg in "$@"; do |
| 20 | if [ "$arg" != "-L" -a "$arg" != "--last" ]; then |
| 21 | ARGS+=("$arg") |
| 22 | fi |
| 23 | done |
| 24 | |
| 25 | exec logcat "${ARGS[@]}" |