|
10 | 10 |
|
11 | 11 | did_relaunch=$1
|
12 | 12 |
|
| 13 | +# Get the user's preferred shell |
| 14 | +preferred_shell=$(basename "$SHELL") |
| 15 | + |
13 | 16 | case "${did_relaunch}" in
|
14 | 17 | "")
|
15 |
| - # Get the user's preferred shell |
16 |
| - preferred_shell=$(basename "$SHELL") |
17 | 18 | if [ "$preferred_shell" = "bash" ]; then
|
18 | 19 | >&2 echo "Preffered shell is bash, relaunching"
|
19 | 20 | exec "$(which bash)" "$0" relaunch
|
|
46 | 47 | if which rtx >/dev/null
|
47 | 48 | then
|
48 | 49 | >&2 echo "rtx executable found in $(which rtx), activating"
|
49 |
| - preferred_shell=$(basename "$SHELL") |
50 | 50 | eval "$($(which rtx) activate "$preferred_shell")"
|
51 | 51 | else
|
52 | 52 | >&2 echo "rtx not found"
|
@@ -92,5 +92,31 @@ export MIX_ENV=prod
|
92 | 92 | # we need to make sure it doesn't interfere with LSP/DAP
|
93 | 93 | echo "" | elixir "$SCRIPTPATH/quiet_install.exs" >/dev/null || exit 1
|
94 | 94 |
|
95 |
| -# shellcheck disable=SC2086 |
96 |
| -exec elixir $ELS_ELIXIR_OPTS --erl "-kernel standard_io_encoding latin1 +sbwt none +sbwtdcpu none +sbwtdio none $ELS_ERL_OPTS" "$SCRIPTPATH/launch.exs" |
| 95 | +default_erl_opts="-kernel standard_io_encoding latin1 +sbwt none +sbwtdcpu none +sbwtdio none" |
| 96 | + |
| 97 | +if [ "$preferred_shell" = "bash" ]; then |
| 98 | + # we need to make sure ELS_ELIXIR_OPTS gets splitted by word |
| 99 | + # parse it as bash array |
| 100 | + # shellcheck disable=SC3045 |
| 101 | + # shellcheck disable=SC3011 |
| 102 | + IFS=' ' read -ra elixir_opts <<< "$ELS_ELIXIR_OPTS" |
| 103 | + # shellcheck disable=SC3054 |
| 104 | + # shellcheck disable=SC2068 |
| 105 | + exec elixir ${elixir_opts[@]} --erl "$default_erl_opts $ELS_ERL_OPTS" "$SCRIPTPATH/launch.exs" |
| 106 | +elif [ "$preferred_shell" = "zsh" ]; then |
| 107 | + # we need to make sure ELS_ELIXIR_OPTS gets splitted by word |
| 108 | + # parse it as zsh array |
| 109 | + # shellcheck disable=SC3030 |
| 110 | + # shellcheck disable=SC2296 |
| 111 | + elixir_opts=("${(z)ELS_ELIXIR_OPTS}") |
| 112 | + # shellcheck disable=SC2128 |
| 113 | + # shellcheck disable=SC2086 |
| 114 | + exec elixir $elixir_opts --erl "$default_erl_opts $ELS_ERL_OPTS" "$SCRIPTPATH/launch.exs" |
| 115 | +else |
| 116 | + if [ -z "$ELS_ELIXIR_OPTS" ] |
| 117 | + then |
| 118 | + # in posix shell does not support arrays |
| 119 | + >&2 echo "ELS_ELIXIR_OPTS is not supported in current shell" |
| 120 | + fi |
| 121 | + exec elixir --erl "$default_erl_opts $ELS_ERL_OPTS" "$SCRIPTPATH/launch.exs" |
| 122 | +fi |
0 commit comments