diff options
author | Jiachen Yang | 2016-05-23 21:47:13 +0900 |
---|---|---|
committer | Jiachen Yang | 2016-05-23 21:47:13 +0900 |
commit | ac8b6d06ec4955bceb39e4716b5d46fcaa39a5d5 (patch) | |
tree | f874484e311ddb86dec112e3105022ef9374a10b | |
parent | 54f54b4234a6f61a1468b2a6bd6b5814a871cdfe (diff) | |
download | aur-ac8b6d06ec4955bceb39e4716b5d46fcaa39a5d5.tar.gz |
arthur2e5 lint for shell scripts
-rw-r--r-- | PKGBUILD | 4 | ||||
-rwxr-xr-x | analyze-shutdown | 32 |
2 files changed, 20 insertions, 16 deletions
@@ -1,6 +1,6 @@ # Maintainer: Jiachen Yang <farseerfc@gmail.com> pkgname=systemd-shutdown-diagnose -pkgver=4 +pkgver=5 pkgrel=1 pkgdesc="help to diagnose shutdown sequence for systemd" arch=(any) @@ -12,7 +12,7 @@ source=('analyze-shutdown' 'shutdown-diagnose.service' 'start-diagnose-shutdown' ) -sha512sums=('883b12b23cad21f620fb10e6f682390d155da65f41517701296793e7ad4ca16e55547b78d3fb06dd697a261e5f236e5d96e6d6c539d16ed3a7b52f890066ac59' +sha512sums=('feb9d7a5ab06a6d89026564041aff0524d20594befa9e4ba628340fcb34a16e6bacdb1c99425e27d5335f5019f2a1c03fc1565bd88e7115241beea49ebb800ac' 'ab00ff35e6e74f90589587c44d3efc4584f0d5d40e7767ee2fc982f2b20f0656dfbb58b3c3a8103a32538a28bb08dd15087114aae0b1f6f73a12b6073d32c99f' '26faec19537be2d4dad83e16a3557d1ab20f71a3f66abbfb8725e7fd9233fef6df2c21c81f5c48c48963746d8b319483615a25ae1fb49f8b3667f30e6b1418ec' '2ee770dce7cbf95d07b49e24522c6be2d7dd8f3cbe88097d6b27a9ea05052525ef58ef6c2f95bf09bcbc38db46918098faf13655c0f6853b3057dac9ec10e6bb') diff --git a/analyze-shutdown b/analyze-shutdown index 40e0919d13e5..0e304a1b76f2 100755 --- a/analyze-shutdown +++ b/analyze-shutdown @@ -1,4 +1,7 @@ #!/bin/bash +[ "$BASH" ] || { echo "Use bash >= 4"; exit 2; } +((BASH_VERSINFO[0] >= 4)) || { echo "Use bash >= 4"; exit 2; } + declare -A kill_time declare -A exit_time declare -a exit_seq @@ -29,7 +32,7 @@ set_exit_time() fi exit_time[$2]=$1 - exit_seq+=($pid) + exit_seq+=("$pid") } # pid, target_pid, signo @@ -44,14 +47,15 @@ add_signal() recv_sig[$2]+=" $3($1)" } +# https://kernel.org/doc/Documentation/trace/ftrace.txt declare -i lineno=0 -while read line; do +while read -r line; do let lineno++ - if [[ 0 == ${#line} ]] || [[ '#' == ${line:0:1} ]]; then + if [[ $line == '' || $line == '#'* ]]; then continue fi - cols=($line) + read -r -a cols <<< "$line" comm=${cols[0]%-*} pid=${cols[0]#$comm-} ts=${cols[3]%:} @@ -64,7 +68,7 @@ while read line; do ts=0 else zeros=000000 - ts=$(($ts-$shut_time)) + ((ts-=shut_time)) if (( 6 >= ${#ts} )); then ts=${zeros:0:7-${#ts}}$ts fi @@ -73,7 +77,7 @@ while read line; do case "$func" in sched_process_exit) - set_exit_time $ts $pid + set_exit_time "$ts" "$pid" comm="${cols[5]#comm=}" ;; sys_kill | sys_tgkill) @@ -81,8 +85,8 @@ while read line; do if [[ '0x0' != "${cols[6]}" ]]; then target_pid=${killer[$pid]##*>} if [[ "$target_pid" ]]; then - add_killer $pid $target_pid $signo - set_exit_time $ts $target_pid + add_killer "$pid" "$target_pid" "$signo" + set_exit_time "$ts" "$target_pid" fi fi else @@ -92,24 +96,24 @@ while read line; do else let signo=0x${cols[9]%)} fi - set_kill_time $ts $target_pid $signo - add_killer $pid $target_pid $signo + set_kill_time "$ts" "$target_pid" "$signo" + add_killer "$pid" "$target_pid" "$signo" fi ;; signal_deliver) let signo=${cols[5]#sig=} - add_signal $ts $pid $signo + add_signal "$ts" "$pid" "$signo" ;; sys_exit) - set_kill_time $ts $pid - + set_kill_time "$ts" "$pid" - ;; esac - if [[ -z "${pid_comm[$pid]}" ]] || [[ '<...>' == "${pid_comm[$pid]}" ]]; then + if [[ -z "${pid_comm[$pid]}" || '<...>' == "${pid_comm[$pid]}" ]]; then pid_comm[$pid]=$comm fi done for pid in "${exit_seq[@]}"; do - printf "%15s(%4s) exited at %10ss, got signals: %s\n" ${pid_comm[$pid]} $pid ${exit_time[$pid]} "${recv_sig[$pid]}" + printf "%15s(%4s) exited at %10ss, got signals: %s\n" "${pid_comm[$pid]}" "$pid" "${exit_time[$pid]}" "${recv_sig[$pid]}" done |