-
Notifications
You must be signed in to change notification settings - Fork 450
Update EmuHawkMono.sh #4594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cD1rtX3
wants to merge
7
commits into
TASEmulators:master
Choose a base branch
from
cD1rtX3:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update EmuHawkMono.sh #4594
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
98287a4
Update EmuHawkMono.sh
cD1rtX3 4e698e2
Fix missing return
cD1rtX3 88d783f
Merge branch 'TASEmulators:master' into master
cD1rtX3 ff2a2ab
Improve script recognition, exit properly, and comply with style guide
cD1rtX3 cdf46cf
Merge branch 'TASEmulators:master' into master
cD1rtX3 5bc71a6
Fix improper exit
cD1rtX3 2ad5991
Properly redirect all status messages
cD1rtX3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,62 @@ | ||
| #!/bin/sh | ||
| cd "$(dirname "$(realpath "$0")")" | ||
|
|
||
| case "$0" in | ||
| *".sh");; | ||
| *"/bin/"*"sh") | ||
| # Very bad way to detect /path/to/shell | ||
| echo "I don't know where I am! Could you run me as \"/path/to/EmuHawkMono.sh\"?" >& 2 | ||
| # stupid bash workaround | ||
| # shellcheck disable=SC2317 | ||
| return 1 2> /dev/null || exit 1;; | ||
| *"/"*);; | ||
| *) | ||
| echo "I don't know where I am! Could you run me as \"/path/to/EmuHawkMono.sh\"?" >& 2 | ||
| # shellcheck disable=SC2317 | ||
| return 1 2> /dev/null || exit 1 | ||
| esac | ||
| if ! cd "$(dirname -- "$(realpath -- "$0")")"; then | ||
| echo "Can't navigate to \$0's path?" >& 2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| libpath="" | ||
| if [ "$(command -v lsb_release)" ]; then | ||
| # shellcheck disable=SC2018,SC2019 | ||
| case "$(lsb_release -i | head -n1 | cut -c17- | tr A-Z a-z)" in | ||
| "arch"|"artix"|"manjarolinux") libpath="/usr/lib";; | ||
| "fedora"|"gentoo"|"nobaralinux"|"opensuse") libpath="/usr/lib64";; | ||
| "nixos") libpath="/usr/lib"; printf "Running on NixOS? Why aren't you using the Nix expr?\n";; | ||
| "nixos") libpath="/usr/lib"; echo "Running on NixOS? Why aren't you using the Nix expr?" >& 2;; | ||
| "debian"|"linuxmint"|"pop"|"ubuntu") libpath="/usr/lib/x86_64-linux-gnu";; | ||
| esac | ||
| else | ||
| printf "Distro does not provide LSB release info API! (You've met with a terrible fate, haven't you?)\n" | ||
| echo "Distro does not provide LSB release info API! (You've met with a terrible fate, haven't you?)" >& 2 | ||
| fi | ||
| if [ -z "$libpath" ]; then | ||
| printf "%s\n" "Unknown distro, assuming system-wide libraries are in /usr/lib..." | ||
| echo "Unknown distro, assuming system-wide libraries are in /usr/lib..." >& 2 | ||
| libpath="/usr/lib" | ||
| fi | ||
|
|
||
| export GTK_DATA_PREFIX="" | ||
| export LD_LIBRARY_PATH="$PWD/dll:$PWD:$libpath" | ||
| export MONO_CRASH_NOFILE=1 | ||
| export MONO_WINFORMS_XIM_STYLE=disabled # see https://bugzilla.xamarin.com/show_bug.cgi?id=28047#c9 | ||
|
|
||
| if [ "$1" = "--mono-no-redirect" ]; then | ||
| # printf "(passing --mono-no-redirect is no longer necessary)\n" #TODO uncomment later | ||
| echo "(passing --mono-no-redirect is no longer necessary)" >& 2 | ||
| shift | ||
| fi | ||
| # shellcheck disable=SC2009 | ||
| if (ps -C "mono" -o "cmd" --no-headers | grep -Fq "EmuHawk.exe"); then | ||
| printf "(it seems EmuHawk is already running, NOT capturing output)\n" >&2 | ||
| exec mono EmuHawk.exe "$@" | ||
| echo "(it seems EmuHawk is already running, NOT capturing output)" >& 2 | ||
| mono EmuHawk.exe "$@" | ||
| exit "$?" | ||
| fi | ||
|
|
||
| o="$(mktemp -u)" | ||
| e="$(mktemp -u)" | ||
| mkfifo "$o" "$e" | ||
| printf "(capturing output in %s/EmuHawkMono_last*.txt)\n" "$PWD" >&2 | ||
| tee EmuHawkMono_laststdout.txt <"$o" & | ||
| tee EmuHawkMono_laststderr.txt <"$e" | sed "s/.*/$(tput setaf 1)&$(tput sgr0)/" >&2 & | ||
| exec mono EmuHawk.exe "$@" >"$o" 2>"$e" | ||
| echo "(capturing output in $PWD/EmuHawkMono_last*.txt)" >& 2 | ||
| tee EmuHawkMono_laststdout.txt < "$o" & | ||
| tee EmuHawkMono_laststderr.txt < "$e" | sed "s/.*/$(tput setaf 1)&$(tput sgr0)/" >& 2 & | ||
| mono EmuHawk.exe "$@" > "$o" 2> "$e" | ||
| exit "$?" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.