## Common shell functions used by demo scripts programs/*/*.sh. ## How to write a demo script ## ========================== ## ## Include this file near the top of each demo script: ## . "${0%/*}/../demo_common.sh" ## ## Start with a "msg" call that explains the purpose of the script. ## Then call the "depends_on" function to ensure that all config ## dependencies are met. ## ## As the last thing in the script, call the cleanup function. ## ## You can use the functions and variables described below. set -e -u ## $root_dir is the root directory of the Mbed TLS source tree. root_dir="${0%/*}" n=4 # limit the search depth while ! [ -d "$root_dir/programs" ] || ! [ -d "$root_dir/library" ]; do if [ $n -eq 0 ]; then echo >&2 "This doesn't seem to be an Mbed TLS source tree." exit 125 fi n=$((n - 1)) case $root_dir in .) root_dir="..";; ..|?*/..) root_dir="$root_dir/..";; ?*/*) root_dir="${root_dir%/*}";; /*) root_dir="/";; *) root_dir=".";; esac done ## $programs_dir is the directory containing the sample programs. programs_dir="$root_dir/programs" ## msg LINE... ## msg &2 <