diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000000..c04764598d --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,20 @@ +name: Shellcheck + +on: + push: + branches: [ main ] + pull_request: + merge_group: + workflow_dispatch: + +jobs: + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install shellcheck + run: sudo apt update && sudo apt install --assume-yes shellcheck + + - name: Run shellcheck + run: find . -name \*.sh -o -name \*.sh.template | xargs shellcheck --severity=warning diff --git a/build.sh b/build.sh index fdff0c6236..c7627404ac 100755 --- a/build.sh +++ b/build.sh @@ -29,7 +29,8 @@ function FirstJsonValue { # If dotnet CLI is installed globally and it matches requested version, use for execution if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then - export DOTNET_EXE="$(command -v dotnet)" + DOTNET_EXE="$(command -v dotnet)" + export DOTNET_EXE else # Download install script DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" diff --git a/instrument.sh b/instrument.sh index a0d23182fb..c77c436555 100755 --- a/instrument.sh +++ b/instrument.sh @@ -169,4 +169,4 @@ if [ "$ENABLE_PROFILING" = "true" ]; then fi fi -$@ +exec "$@" diff --git a/nuget/OpenTelemetry.AutoInstrumentation/contentFiles/any/any/instrument.sh b/nuget/OpenTelemetry.AutoInstrumentation/contentFiles/any/any/instrument.sh index 0d766c904d..1a8d13158f 100755 --- a/nuget/OpenTelemetry.AutoInstrumentation/contentFiles/any/any/instrument.sh +++ b/nuget/OpenTelemetry.AutoInstrumentation/contentFiles/any/any/instrument.sh @@ -1,16 +1,17 @@ #!/bin/sh -BASE_PATH="$(cd $(dirname "$0") && pwd)" +BASE_PATH="$(cd "$(dirname "$0")" && pwd)" # Settings for .NET export ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=OpenTelemetry.AutoInstrumentation.AspNetCoreBootstrapper export CORECLR_ENABLE_PROFILING=1 export CORECLR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}" -export CORECLR_PROFILER_PATH=$(ls ${BASE_PATH}/OpenTelemetry.AutoInstrumentation.Native.*) +CORECLR_PROFILER_PATH="$(ls ${BASE_PATH}/OpenTelemetry.AutoInstrumentation.Native.*)" +export CORECLR_PROFILER_PATH export DOTNET_STARTUP_HOOKS=${BASE_PATH}/OpenTelemetry.AutoInstrumentation.StartupHook.dll # Settings for OpenTelemetry export OTEL_DOTNET_AUTO_HOME=${BASE_PATH} export OTEL_DOTNET_AUTO_RULE_ENGINE_ENABLED=false -$@ +exec "$@" diff --git a/scripts/format-native.sh b/scripts/format-native.sh index 9b963813ce..584916d6ed 100755 --- a/scripts/format-native.sh +++ b/scripts/format-native.sh @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/bash +set -e SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) cd $SCRIPT_DIR/.. @@ -31,7 +32,7 @@ else fi # files to format -NATIVE_FILES=$(find . -iname *.cpp -o -iname *.hpp -iname *.h -iname *.inc | grep -v ./packages | grep -v ./src/OpenTelemetry.AutoInstrumentation.Native/lib) +NATIVE_FILES=$(find . -iname "*.cpp" -o -iname "*.hpp" -iname "*.h" -iname "*.inc" | grep -v ./packages | grep -v ./src/OpenTelemetry.AutoInstrumentation.Native/lib) # clang-format echo "$NATIVE_FILES" | xargs "./bin/artifacts/clang-format$EXT" -style=file -i