Use shfmt as formatter for shell scripts

This commit is contained in:
ChillerDragon 2024-05-23 08:03:03 +08:00
parent 1e11fffb03
commit c75584406a
14 changed files with 113 additions and 141 deletions

2
.editorconfig Normal file
View file

@ -0,0 +1,2 @@
[*.sh]
space_redirects = true

View file

@ -23,6 +23,8 @@ jobs:
sudo apt-get install clang-format imagemagick ddnet-tools shellcheck pkg-config cmake ninja-build libfreetype6-dev libnotify-dev libsdl2-dev libsqlite3-dev libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libx264-dev python3-clang libvulkan-dev glslang-tools spirv-tools -y
rustup default stable
pip3 install pylint
wget -O ~/.local/bin/shfmt https://github.com/mvdan/sh/releases/download/v3.8.0/shfmt_v3.8.0_linux_amd64
chmod +x ~/.local/bin/shfmt
git clone https://gitlab.com/Patiga/twmap.git/
cd twmap/twmap-tools
cargo install --locked --path=.
@ -60,6 +62,8 @@ jobs:
# fi
- name: Shellcheck
run: find . -type f -name '*.sh' -print0 | xargs -0 shellcheck
- name: Shell format (shfmt)
run: find . -type f -name '*.sh' -print0 | xargs -0 shfmt -d
- name: Check log error case
run: |
if grep -Eqr '(msg|Print).*\(.*"[Ee]rror:' src/;

View file

@ -1,10 +1,10 @@
#!/usr/bin/env bash
command -v a2x >/dev/null 2>&1 || {
echo >&2 "You need asciidoc installed";
echo >&2 "Debian/Ubuntu: sudo apt install asciidoc";
echo >&2 "http://asciidoc.org/";
exit 1;
command -v a2x > /dev/null 2>&1 || {
echo >&2 "You need asciidoc installed"
echo >&2 "Debian/Ubuntu: sudo apt install asciidoc"
echo >&2 "http://asciidoc.org/"
exit 1
}
set -ex
@ -20,4 +20,3 @@ EOF
a2x --doctype manpage --format manpage DDNet.adoc
a2x --doctype manpage --format manpage DDNetServer.adoc

View file

@ -1,22 +1,25 @@
#!/bin/sh
case "$(uname -s)" in
CYGWIN*|MINGW*|MSYS*)
if [ -d "$APPDATA/DDNet/" ]; then
explorer "$APPDATA/DDNet/"
else
explorer "$APPDATA/Teeworlds/"
fi;;
Darwin*)
if [ -d "$HOME/Library/Application Support/DDNet/" ]; then
open "$HOME/Library/Application Support/DDNet/"
else
open "$HOME/Library/Application Support/Teeworlds/"
fi;;
*)
DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
if [ -d "$DATA_HOME/ddnet/" ]; then
xdg-open "$DATA_HOME/ddnet/"
else
xdg-open "$HOME/.teeworlds/"
fi;;
CYGWIN* | MINGW* | MSYS*)
if [ -d "$APPDATA/DDNet/" ]; then
explorer "$APPDATA/DDNet/"
else
explorer "$APPDATA/Teeworlds/"
fi
;;
Darwin*)
if [ -d "$HOME/Library/Application Support/DDNet/" ]; then
open "$HOME/Library/Application Support/DDNet/"
else
open "$HOME/Library/Application Support/Teeworlds/"
fi
;;
*)
DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
if [ -d "$DATA_HOME/ddnet/" ]; then
xdg-open "$DATA_HOME/ddnet/"
else
xdg-open "$HOME/.teeworlds/"
fi
;;
esac

View file

@ -24,35 +24,35 @@ _ANDROID_SUB_BUILD_DIR=build_arch
_SHOW_USAGE_INFO=0
if [ -z ${1+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass android build type, using default: ${_DEFAULT_ANDROID_BUILD}"
printf "\e[31m%s\e[30m\n" "Did not pass android build type, using default: ${_DEFAULT_ANDROID_BUILD}"
_SHOW_USAGE_INFO=1
else
_DEFAULT_ANDROID_BUILD=$1
fi
if [ -z ${2+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass game name, using default: ${_DEFAULT_GAME_NAME}"
printf "\e[31m%s\e[30m\n" "Did not pass game name, using default: ${_DEFAULT_GAME_NAME}"
_SHOW_USAGE_INFO=1
else
_DEFAULT_GAME_NAME=$2
fi
if [ -z ${3+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass package name, using default: ${_DEFAULT_PACKAGE_NAME}"
printf "\e[31m%s\e[30m\n" "Did not pass package name, using default: ${_DEFAULT_PACKAGE_NAME}"
_SHOW_USAGE_INFO=1
else
_DEFAULT_PACKAGE_NAME=$3
fi
if [ -z ${4+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass build type, using default: ${_DEFAULT_BUILD_TYPE}"
printf "\e[31m%s\e[30m\n" "Did not pass build type, using default: ${_DEFAULT_BUILD_TYPE}"
_SHOW_USAGE_INFO=1
else
_DEFAULT_BUILD_TYPE=$4
fi
if [ -z ${5+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass build folder, using default: ${_DEFAULT_BUILD_FOLDER}"
printf "\e[31m%s\e[30m\n" "Did not pass build folder, using default: ${_DEFAULT_BUILD_FOLDER}"
_SHOW_USAGE_INFO=1
else
_DEFAULT_BUILD_FOLDER=$5
@ -63,17 +63,17 @@ _ANDROID_JAR_KEY_PW=android
_ANDROID_JAR_KEY_ALIAS=androiddebugkey
if [ -z ${TW_KEY_NAME+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass a key for the jar signer, using default: ${_ANDROID_JAR_KEY_NAME}"
printf "\e[31m%s\e[30m\n" "Did not pass a key for the jar signer, using default: ${_ANDROID_JAR_KEY_NAME}"
else
_ANDROID_JAR_KEY_NAME=$TW_KEY_NAME
fi
if [ -z ${TW_KEY_PW+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass a key pw for the jar signer, using default: ${_ANDROID_JAR_KEY_PW}"
printf "\e[31m%s\e[30m\n" "Did not pass a key pw for the jar signer, using default: ${_ANDROID_JAR_KEY_PW}"
else
_ANDROID_JAR_KEY_PW=$TW_KEY_PW
fi
if [ -z ${TW_KEY_ALIAS+x} ]; then
printf "\e[31m%s\e[30m\n" "Did not pass a key alias for the jar signer, using default: ${_ANDROID_JAR_KEY_ALIAS}"
printf "\e[31m%s\e[30m\n" "Did not pass a key alias for the jar signer, using default: ${_ANDROID_JAR_KEY_ALIAS}"
else
_ANDROID_JAR_KEY_ALIAS=$TW_KEY_ALIAS
fi
@ -110,8 +110,8 @@ export TW_VERSION_NAME=$_ANDROID_VERSION_NAME
printf "\e[31m%s\e[1m\n" "Building with setting, for arch: ${_DEFAULT_ANDROID_BUILD}, with build type: ${_DEFAULT_BUILD_TYPE}, with name: ${_DEFAULT_GAME_NAME} (${_DEFAULT_PACKAGE_NAME})"
if [ $_SHOW_USAGE_INFO == 1 ]; then
printf "\e[31m%s\e[1m\n" "Usage: ./cmake_android.sh <x86/x86_64/arm/arm64/all> <Game name> <Package name> <Debug/Release> <Build folder>"
if [ $_SHOW_USAGE_INFO == 1 ]; then
printf "\e[31m%s\e[1m\n" "Usage: ./cmake_android.sh <x86/x86_64/arm/arm64/all> <Game name> <Package name> <Debug/Release> <Build folder>"
fi
printf "\e[33mBuilding cmake\e[0m\n"

View file

@ -1,17 +1,17 @@
#!/bin/bash
[ "$1" == "" ] && {
printf '\e[31mDid not pass APK name to build script\e[30m\n'
printf '\e[31mDid not pass APK name to build script\e[30m\n'
exit 1
}
[ "$2" == "" ] && {
printf '\e[31mDid not pass package name to build script\e[30m\n'
printf '\e[31mDid not pass package name to build script\e[30m\n'
exit 1
}
[ "$3" == "" ] && {
printf '\e[31mDid not pass build type to build script\e[30m\n'
printf '\e[31mDid not pass build type to build script\e[30m\n'
exit 1
}
@ -19,15 +19,15 @@ _APK_BASENAME="$1"
_APK_PACKAGE_NAME="$2"
_APK_BUILD_TYPE="$3"
_APK_PACKAGE_FOLDER=$(echo "$_APK_PACKAGE_NAME"|sed 's/\./\//g')
_APK_PACKAGE_FOLDER=$(echo "$_APK_PACKAGE_NAME" | sed 's/\./\//g')
sed -i "s/DDNet/${_APK_BASENAME}/g" settings.gradle
sed -i "s/org.ddnet.client/${_APK_PACKAGE_NAME}/g" build.gradle
TW_KEY_NAME_ESCAPED=$(echo "$TW_KEY_NAME"|sed 's/\//\\\//g')
TW_KEY_PW_ESCAPED=$(echo "$TW_KEY_PW"|sed 's/\//\\\//g')
TW_KEY_ALIAS_ESCAPED=$(echo "$TW_KEY_ALIAS"|sed 's/\//\\\//g')
TW_KEY_NAME_ESCAPED=$(echo "$TW_KEY_NAME" | sed 's/\//\\\//g')
TW_KEY_PW_ESCAPED=$(echo "$TW_KEY_PW" | sed 's/\//\\\//g')
TW_KEY_ALIAS_ESCAPED=$(echo "$TW_KEY_ALIAS" | sed 's/\//\\\//g')
sed -i "s/TW_KEY_NAME/${TW_KEY_NAME_ESCAPED}/g" build.gradle
sed -i "s/TW_KEY_PW/${TW_KEY_PW_ESCAPED}/g" build.gradle
@ -65,7 +65,7 @@ if [[ -z ${GE_NO_APK_BUILD} || "${GE_NO_APK_BUILD}" != "1" ]]; then
_RELEASE_TYPE_NAME=release
_RELEASE_TYPE_APK_NAME=
fi
APP_BASE_NAME=Gradle
CLASSPATH=gradle-wrapper.jar
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all
@ -77,11 +77,10 @@ if [[ -z ${GE_NO_APK_BUILD} || "${GE_NO_APK_BUILD}" != "1" ]]; then
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all assembleRelease
fi
cp build/outputs/apk/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".apk "$_APK_BASENAME".apk
if [[ "${_APK_BUILD_TYPE}" == "Release" ]]; then
java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all bundleRelease
cp build/outputs/bundle/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME""$_RELEASE_TYPE_APK_NAME".aab "$_APK_BASENAME".aab
fi
fi

View file

@ -5,7 +5,7 @@ c_headers=(assert complex ctype errno fenv float inttypes iso646 limits locale m
c_headers_map=(cassert complex cctype cerrno cfenv cfloat cinttypes ciso646 climits clocale cmath csetjmp csignal cstdarg cstdbool cstddef cstdint cstdio cstdlib cstring ctgmath ctime cwchar cwctype)
# Create regex dynamically from the array to match any C header
c_headers_regex=$(IFS="|"; echo "${c_headers[*]}")
c_headers_regex=$(printf "%s" "${c_headers[*]}" | tr ' ' '|')
# Find all C++ source and header files
files=$(find ./src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' \) ! -path "./src/engine/external/*")
@ -15,10 +15,10 @@ error_found=0
# Check each source file for C headers
for file in $files; do
# First check if the file includes any C headers for more efficiency when no C header is used
if grep -E "#include\s+<($c_headers_regex)\.h>" "$file" >/dev/null; then
if grep -E "#include\s+<($c_headers_regex)\.h>" "$file" > /dev/null; then
# Check each C header individually to print an error message with the appropriate replacement C++ header
for (( i=0; i < ${#c_headers[@]}; i++ )); do
if grep -E "#include\s+<${c_headers[i]}\.h>" "$file" >/dev/null; then
for ((i = 0; i < ${#c_headers[@]}; i++)); do
if grep -E "#include\s+<${c_headers[i]}\.h>" "$file" > /dev/null; then
echo "Error: '$file' includes C header '${c_headers[i]}.h'. Include the C++ header '${c_headers_map[i]}' instead."
fi
done

View file

@ -11,7 +11,7 @@ if [[ "${2}" == "webasm" ]]; then
COMPILEFLAGS="-pthread -O3 -g -s USE_PTHREADS=1"
LINKFLAGS="-pthread -O3 -g -s USE_PTHREADS=1 -s ASYNCIFY=1"
fi
COMPILEFLAGS=$3
LINKFLAGS=$4

View file

@ -1,18 +1,18 @@
#!/bin/bash
CURDIR="$PWD"
if [ -z ${1+x} ]; then
if [ -z ${1+x} ]; then
echo "Give a destination path where to run this script, please choose a path other than in the source directory"
exit 1
fi
if [ -z ${2+x} ]; then
if [ -z ${2+x} ]; then
echo "Specify the target system"
exit 1
fi
OS_NAME=$2
COMPILEFLAGS="-fPIC"
LINKFLAGS="-fPIC"
if [[ "${OS_NAME}" == "webasm" ]]; then

View file

@ -25,7 +25,7 @@ function buid_openssl() {
if [[ "$_EXISTS_PROJECT" == "0" ]]; then
if [[ "${4}" == "webasm" ]]; then
emconfigure ../Configure "$2" -no-tests -no-asm -static -no-afalgeng -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 -DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 --with-rand-seed=getrandom
sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
else
../Configure "$2" no-asm no-shared

View file

@ -77,4 +77,3 @@ function compile_all_opusfile() {
}
compile_all_opusfile "$1" "$2"

View file

@ -32,21 +32,21 @@ function make_sqlite3() {
LDFLAGS="${LINKER_FLAGS} -L./" \
LD_LIBRARY_PATH="$_LD_LIBRARY_PATH" \
${TMP_COMPILER} \
-c \
-fPIC \
-DSQLITE_ENABLE_ATOMIC_WRITE=1 \
-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE=1 \
-DSQLITE_ENABLE_MULTITHREADED_CHECKS=1 \
-DSQLITE_THREADSAFE=1 \
../sqlite3.c \
-o sqlite3.o
-c \
-fPIC \
-DSQLITE_ENABLE_ATOMIC_WRITE=1 \
-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE=1 \
-DSQLITE_ENABLE_MULTITHREADED_CHECKS=1 \
-DSQLITE_THREADSAFE=1 \
../sqlite3.c \
-o sqlite3.o
LDFLAGS="${LINKER_FLAGS} -L./" \
LD_LIBRARY_PATH="$_LD_LIBRARY_PATH" \
${TMP_AR} \
rvs \
sqlite3.a \
sqlite3.o
rvs \
sqlite3.a \
sqlite3.o
)
}
@ -62,4 +62,3 @@ function compile_all_sqlite3() {
}
compile_all_sqlite3 "$1" "$2"

View file

@ -3,10 +3,8 @@
arg_verbose=0
arg_valgrind_memcheck=0
for arg in "$@"
do
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]
then
for arg in "$@"; do
if [ "$arg" == "-h" ] || [ "$arg" == "--help" ]; then
echo "usage: $(basename "$0") [OPTION..]"
echo "description:"
echo " Runs a simple integration test of the client and server"
@ -16,11 +14,9 @@ do
echo " --verbose|-v verbose output"
echo " --valgrind-memcheck use valgrind's memcheck to run server and client"
exit 0
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]
then
elif [ "$arg" == "-v" ] || [ "$arg" == "--verbose" ]; then
arg_verbose=1
elif [ "$arg" == "--valgrind-memcheck" ]
then
elif [ "$arg" == "--valgrind-memcheck" ]; then
arg_valgrind_memcheck=1
else
echo "Error: unknown argument '$arg'"
@ -28,13 +24,11 @@ do
fi
done
if [ ! -f DDNet ]
then
if [ ! -f DDNet ]; then
echo "[-] Error: client binary 'DDNet' not found"
exit 1
fi
if [ ! -f DDNet-Server ]
then
if [ ! -f DDNet-Server ]; then
echo "[-] Error: server binary 'DDNet-Server' not found"
exit 1
fi
@ -44,30 +38,25 @@ got_killed=0
function kill_all() {
# needed to fix hang fifo with additional ctrl+c
if [ "$got_killed" == "1" ]
then
if [ "$got_killed" == "1" ]; then
exit
fi
got_killed=1
if [ "$arg_verbose" == "1" ]
then
if [ "$arg_verbose" == "1" ]; then
echo "[*] Shutting down test clients and server"
fi
sleep 1
if [[ ! -f fail_server.txt ]]
then
if [[ ! -f fail_server.txt ]]; then
echo "[*] Shutting down server"
echo "shutdown" > server.fifo
fi
sleep 1
local i
for ((i=1;i<3;i++))
do
if [[ ! -f fail_client$i.txt ]]
then
for ((i = 1; i < 3; i++)); do
if [[ ! -f fail_client$i.txt ]]; then
echo "[*] Shutting down client$i"
echo "quit" > "client$i.fifo"
fi
@ -81,8 +70,7 @@ function cleanup() {
trap cleanup EXIT
function fail()
{
function fail() {
sleep 1
tail -n2 "$1".log > fail_"$1".txt
echo "$1 exited with code $2" >> fail_"$1".txt
@ -90,7 +78,7 @@ function fail()
}
# Get unused port from the system by binding to port 0 and immediately closing the socket again
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()');
port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')
if [[ $OSTYPE == 'darwin'* ]]; then
DETECT_LEAKS=0
@ -113,8 +101,7 @@ function print_results() {
return 1
fi
else
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
then
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"; then
echo "[-] Error: ASAN has detected the following errors:"
cat SAN.*
return 1
@ -153,15 +140,12 @@ function wait_for_fifo() {
# give the server/client time to launch and create the fifo file
# but assume after X secs that the server/client crashed before
# being able to create the file
while [[ ! -p "$fifo" ]]
do
fails="$((fails+1))"
if [ "$arg_verbose" == "1" ]
then
while [[ ! -p "$fifo" ]]; do
fails="$((fails + 1))"
if [ "$arg_verbose" == "1" ]; then
echo "[!] Note: $fifo not found (attempts $fails/$tries)"
fi
if [ "$fails" -gt "$tries" ]
then
if [ "$fails" -gt "$tries" ]; then
echo "[-] Error: $(basename "$fifo" .fifo) possibly crashed on launch"
kill_all
print_results
@ -282,34 +266,29 @@ fi
# Kill all processes first so all outputs are fully written
kill_all
if ! grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}:){2}[0-9]{2} I chat: 0:-2:client1: hello world$' server.log
then
if ! grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2} ([0-9]{2}:){2}[0-9]{2} I chat: 0:-2:client1: hello world$' server.log; then
touch fail_chat.txt
echo "[-] Error: chat message not found in server log"
fi
if ! grep -q 'cmdlist' client1.log || \
! grep -q 'pause' client1.log || \
! grep -q 'rank' client1.log || \
! grep -q 'points' client1.log
then
if ! grep -q 'cmdlist' client1.log ||
! grep -q 'pause' client1.log ||
! grep -q 'rank' client1.log ||
! grep -q 'points' client1.log; then
touch fail_chatcommand.txt
echo "[-] Error: did not find output of /cmdlist command"
fi
if ! grep -q "hello from admin" server.log
then
if ! grep -q "hello from admin" server.log; then
touch fail_rcon.txt
echo "[-] Error: admin message not found in server log"
fi
if ! grep -q "demo_player: Stopped playback" client1.log
then
if ! grep -q "demo_player: Stopped playback" client1.log; then
touch fail_demo_server.txt
echo "[-] Error: demo playback of server demo in client 1 was not started/finished"
fi
if ! grep -q "demo_player: Stopped playback" client2.log
then
if ! grep -q "demo_player: Stopped playback" client2.log; then
touch fail_demo_client.txt
echo "[-] Error: demo playback of client demo in client 2 was not started/finished"
fi
@ -324,33 +303,27 @@ player: client1 time: 168300.5 cps: 0.02 0.06 0.12 15300.14 15300.18 30600.2 306
player: client2 time: 302.02 cps: 0.42 0.5 0.0 0.66 0.92 0.02 300.18 300.46 300.76 300.88 300.98 301.16 301.24 301.28 301.3 301.86 301.96 0.0 0.0 0.0 0.0 0.0 0.0"
# require at least one rank in all cases. Exact finishes only with valgrind disabled
if [ "$ranks" == "" ]
then
if [ "$ranks" == "" ]; then
touch fail_ranks.txt
echo "[-] Error: no ranks found in database"
elif [ "$arg_valgrind_memcheck" != "1" ] && [ "$rank_time" != "$expected_times" ]
then
elif [ "$arg_valgrind_memcheck" != "1" ] && [ "$rank_time" != "$expected_times" ]; then
touch fail_ranks.txt
echo "[-] Error: unexpected finish time"
echo " expected: $expected_times"
echo " got: $rank_time"
fi
for logfile in client1.log client2.log server.log
do
if [ "$arg_valgrind_memcheck" == "1" ]
then
for logfile in client1.log client2.log server.log; do
if [ "$arg_valgrind_memcheck" == "1" ]; then
break
fi
if [ ! -f "$logfile" ]
then
if [ ! -f "$logfile" ]; then
echo "[-] Error: logfile '$logfile' not found"
touch fail_logs.txt
continue
fi
logdiff="$(diff -u <(grep -v "console: .* access for .* is now .*abled" "$logfile" | sort) <(sort "stdout_$(basename "$logfile" .log).txt"))"
if [ "$logdiff" != "" ]
then
if [ "$logdiff" != "" ]; then
echo "[-] Error: logfile '$logfile' differs from stdout"
echo "$logdiff"
echo "[-] Error: logfile '$logfile' differs from stdout" >> fail_logs.txt
@ -358,24 +331,19 @@ do
fi
done
for stderr in ./stderr_*.txt
do
if [ ! -f "$stderr" ]
then
for stderr in ./stderr_*.txt; do
if [ ! -f "$stderr" ]; then
continue
fi
if [ "$(cat "$stderr")" == "" ]
then
if [ "$(cat "$stderr")" == "" ]; then
continue
fi
echo "[!] Warning: $stderr"
cat "$stderr"
done
if test -n "$(find . -maxdepth 1 -name 'fail_*' -print -quit)"
then
for fail in fail_*
do
if test -n "$(find . -maxdepth 1 -name 'fail_*' -print -quit)"; then
for fail in fail_*; do
cat "$fail"
done
print_results

View file

@ -46,13 +46,12 @@ function prine_line_for_address() {
}
ADDR_PC_REGEX='[0-9A-Fa-f]+ [0-9A-Fa-f]+ [0-9A-Fa-f]+ [0-9A-Fa-f]+'
while read -r line
do
while read -r line; do
if [[ $line =~ $ADDR_PC_REGEX ]]; then
# Check for main executable file with address information
EXE_FILE_RELATIVE_ADDR=$(echo "$line" | grep -E -o -m 1 "\s${EXE_FILE_FILENAME_REGEX}!.*0x[0-9A-Fa-f]+" | grep -E -o "0x[0-9A-Fa-f]+" | head -1)
if [ -n "$EXE_FILE_RELATIVE_ADDR" ]; then
prine_line_for_address "$(printf '0x%X\n' "$((EXE_FILE_RELATIVE_ADDR+ADDR_BASE))")"
prine_line_for_address "$(printf '0x%X\n' "$((EXE_FILE_RELATIVE_ADDR + ADDR_BASE))")"
continue
fi
@ -65,6 +64,6 @@ do
# Compatibilty with old crash logs: use the raw address and assume it belongs to the main executable
RAW_ADDR=$(echo "$line" | grep -E -o -m 1 "[0-9A-Fa-f]+ " | head -1)
prine_line_for_address "$(printf '0x%X\n' "$(((0x$RAW_ADDR-0x$MODULE_OFFSET)+ADDR_BASE))")"
prine_line_for_address "$(printf '0x%X\n' "$(((0x$RAW_ADDR - 0x$MODULE_OFFSET) + ADDR_BASE))")"
fi
done < "$CRASH_LOG_FILE"