mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-29 04:06:40 +00:00
Restore previous bash settings on exit
This commit is contained in:
parent
b71f13965a
commit
70384d8a83
1 changed files with 15 additions and 1 deletions
|
@ -1,13 +1,24 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
oldSettings=$-
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
function restoreOldSettings {
|
||||||
|
if [[ $oldSettings != *e* ]]; then
|
||||||
|
set +e
|
||||||
|
fi
|
||||||
|
if [[ $oldSettings != *u* ]]; then
|
||||||
|
set +u
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
echo "Error: Script not sourced."
|
echo "Error: Script not sourced."
|
||||||
echo "You must source this script for it to work, i.e. "
|
echo "You must source this script for it to work, i.e. "
|
||||||
echo "source ./activate_msvc.sh"
|
echo "source ./activate_msvc.sh"
|
||||||
echo "or"
|
echo "or"
|
||||||
echo ". ./activate_msvc.sh"
|
echo ". ./activate_msvc.sh"
|
||||||
|
restoreOldSettings
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -78,7 +89,10 @@ command -v mt >/dev/null 2>&1 || { echo "Error: mt (MS Windows Manifest Tool) mi
|
||||||
|
|
||||||
if [ $MISSINGTOOLS -ne 0 ]; then
|
if [ $MISSINGTOOLS -ne 0 ]; then
|
||||||
echo "Some build tools were unavailable after activating MSVC in the shell. It's likely that your Visual Studio $MSVC_DISPLAY_YEAR installation needs repairing."
|
echo "Some build tools were unavailable after activating MSVC in the shell. It's likely that your Visual Studio $MSVC_DISPLAY_YEAR installation needs repairing."
|
||||||
|
restoreOldSettings
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS="$originalIFS"
|
IFS="$originalIFS"
|
||||||
|
|
||||||
|
restoreOldSettings
|
Loading…
Reference in a new issue