| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 # This script looks to see if a log file is zero length, or non | 7 # This script looks to see if a log file is zero length, or non |
| 8 # existent before writing something to stdout, so that we don't end up | 8 # existent before writing something to stdout, so that we don't end up |
| 9 # with empty entries that just look broken. | 9 # with empty entries that just look broken. |
| 10 | 10 |
| 11 max_lines=${2:-1000} | 11 max_lines=${2:-1000} |
| 12 | 12 |
| 13 file=$1 | 13 file=$1 |
| 14 if [ -h "$file" ]; then | 14 if [ -h "$file" ]; then |
| 15 file="$(readlink $file)" | 15 file="$(readlink -f $file)" |
| 16 fi | 16 fi |
| 17 | 17 |
| 18 if [ -r "$file" -a -f "$file" ]; then | 18 if [ -r "$file" -a -f "$file" ]; then |
| 19 size=$(/bin/ls -s "$file") | 19 size=$(/bin/ls -s "$file") |
| 20 # Get the first field. | 20 # Get the first field. |
| 21 size=${size%% *} | 21 size=${size%% *} |
| 22 if [ $size -gt 0 ]; then | 22 if [ $size -gt 0 ]; then |
| 23 /usr/bin/tail --lines=$max_lines "$file" | 23 /usr/bin/tail --lines=$max_lines "$file" |
| 24 else | 24 else |
| 25 echo "<empty>" | 25 echo "<empty>" |
| 26 fi | 26 fi |
| 27 else | 27 else |
| 28 echo "<not available>" | 28 echo "<not available>" |
| 29 fi | 29 fi |
| OLD | NEW |