#  Sed script to adapt init.sh and init.cfg in ./tests.

/^ME_=/ i\
export PATH_SEPARATOR=${PATH_SEPARATOR=:}

# Support TMPDIR, TMP and TEMP in remove_tmp_ too.
/^remove_tmp_[ 	]*()/,/^}$/ {
  /cd.*initial_cwd_/ s/||/& cd "${TMPDIR=${TMP=${TEMP=..}}}" & /
}

# path_prepend_ is not able to handle paths with DOS specific drive specifiers.
# It assumes that colons are path separators.
/^path_prepend_[ 	]*()/,/^}$/ {
  /PATH=/ s/:/\${PATH_SEPARATOR}/
  /^[ 	]*\*:\*)/ s/\*:\*)/*\${PATH_SEPARATOR}*)/
  /^[ 	]*\/\*)/  s,\/\*),[A-z]:[\\/]* | [\\/]*),
}

# mktempd_ is not able to handle paths with DOS specific drive specifiers.
# It assumes that colons are path separators.
/^mktempd_[ 	]*()/,/^}$/ {
  /^[ 	]*\*\/)/ s,\*\/),*[\\/]),
  /^[ 	]*\/)/   s,\/),[A-z]:[\\/] | [\\/]),

  # Do not clobber the TMPDIR.
  /d=/ s/unset TMPDIR;/& unset TMP; unset TEMP;/

  /drwx------/ s/;;/;; ----d-*) ;;/
}
