From acce32db93d914d6e9d94d0b28a246a7d57e2253 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 27 Mar 2015 22:54:14 +0100 Subject: sslkeylog.sh: allow it to be sourced Switch to bash as there is no readable / easy way to make it compatible for all shells in the world. --- src/sslkeylog.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sslkeylog.sh b/src/sslkeylog.sh index b5bac94..0197302 100755 --- a/src/sslkeylog.sh +++ b/src/sslkeylog.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Invokes the given command, displaying the pre-master secrets to stderr # (or to the file given by envvar SSLKEYLOGFILE). # @@ -15,8 +15,10 @@ gdb() { "$@" } -export LD_PRELOAD=$(dirname "$0")/libsslkeylog.so -export SSLKEYLOGFILE=${SSLKEYLOGFILE:-/dev/stderr} +LD_PRELOAD=$(readlink -f "${BASH_SOURCE[0]%/*}")/libsslkeylog.so +SSLKEYLOGFILE=${SSLKEYLOGFILE:-/dev/stderr} +export LD_PRELOAD SSLKEYLOGFILE -# Run the command +# Run the command (if not sourced) +[[ ${BASH_SOURCE[0]} != $0 ]] || \ "$@" -- cgit v1.2.1