Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion setup-stage1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,16 @@ declare -a FFXIV_ENVIRON_REQUIRED=(
IFS=\| eval 'FFXIV_ENVIRON_REQ_RGX="^export (${FFXIV_ENVIRON_REQUIRED[*]})="'

# Extract the currently running Lutris environment as properly quoted, newline-separated values.
FFXIV_ENVIRON="$(cat /proc/$FFXIV_PID/environ | xargs -0 bash -c 'printf "export %q\n" "$@"' --)"
get_ffxiv_pid_environ() {
if cat "/proc/$FFXIV_PID/environ" 2>/dev/null; then
return 0
fi
echo "Failed to cat /proc/$FFXIV_PID/environ. This can sometimes happen if your operating system only allows this action by root. We will try to rerun this command with sudo. You may be prompted for your password. The commands we will run with sudo are:" >&2
echo >&2
echo " sudo cat /proc/$FFXIV_PID/environ" >&2
sudo cat /proc/$FFXIV_PID/environ
Comment on lines +125 to +128

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should display this message with a different color to indicate that it's more important. Use warn.

Additionally, we should always prompt before running something as sudo, so that the user can interrupt if it doesn't look correct.

Finally, a minor grammar correction.

Suggested change
echo "Failed to cat /proc/$FFXIV_PID/environ. This can sometimes happen if your operating system only allows this action by root. We will try to rerun this command with sudo. You may be prompted for your password. The commands we will run with sudo are:" >&2
echo >&2
echo " sudo cat /proc/$FFXIV_PID/environ" >&2
sudo cat /proc/$FFXIV_PID/environ
warn "Failed to cat /proc/$FFXIV_PID/environ. This can sometimes happen if your operating system only allows this action by root. We will try to rerun this command with sudo. You may be prompted for your password. The command we will run with sudo is:"
echo >&2
warn " sudo cat /proc/$FFXIV_PID/environ"
PROMPT_CONTINUE
sudo cat /proc/$FFXIV_PID/environ

}
FFXIV_ENVIRON="$(get_ffxiv_pid_environ | xargs -0 bash -c 'printf "export %q\n" "$@"' --)"

# Grab only the exact environment variables that we want.
FFXIV_ENVIRON_FINAL="$(echo "$FFXIV_ENVIRON" | grep -P "$FFXIV_ENVIRON_REQ_RGX")"
Expand Down