#!/bin/sh

DIR_NAME=$(dirname "$0")

# Create a temporary directory in /tmp
TEMP_DIR=$(mktemp -d -p /tmp "json_drop_keys_udf_XXXXXXXXXX")

# Trap to clean up the temporary directory on exit
trap 'rm -rf "$TEMP_DIR"; exit' 0

# Determine which executable to use based on architecture
case $( uname -m ) in
aarch64)
    EXECUTABLE_NAME="json_drop_keys_udf_aarch64"
    ;;
*)
    EXECUTABLE_NAME="json_drop_keys_udf_x86_64"
    ;;
esac

# Copy the executable to a temporary location
cp "$DIR_NAME/$EXECUTABLE_NAME" "$TEMP_DIR/$EXECUTABLE_NAME"
chmod +x "$TEMP_DIR/$EXECUTABLE_NAME"
"$TEMP_DIR/$EXECUTABLE_NAME" "$@"
