#! /bin/sh

ERL_CRASH_DUMP=/dev/null
export ERL_CRASH_DUMP

echo "the following fails ..."

erl -pa `pwd`/sup-new/ebin -noshell -noinput -eval "
  ok = application:start (sup),
  { ok, _ } = release_handler:downgrade_app (sup, \"0.0.0\", \"`pwd`/sup-old\")
" -s erlang halt

echo "i think b/c release_handler:get_vsn/1 is assuming the module to be deleted is already loaded."

echo "this theory suggests the following should work ..."

erl -pa `pwd`/sup-new/ebin -noshell -noinput -eval "
  ok = application:start (sup),
  erlrctestmakeappupdild:module_info (),
  { ok, _ } = release_handler:downgrade_app (sup, \"0.0.0\", \"`pwd`/sup-old\")
" -s erlang halt || exit 1

echo "and it does!"
