Skip to content
This repository was archived by the owner on Mar 25, 2023. It is now read-only.
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
31 changes: 20 additions & 11 deletions lib/project-shell-env.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ shellEscape = ( string ) ->
getShellEnv = ( path, timeout = 1000 ) ->
# SHELL env variable contains user's shell even when atom is launched from GUI
shell = process.env[ "SHELL" ] ? "bash"
shellName = shell.split('/').pop()

# List of flags with which shell will be invoked
shellFlags = [
Expand All @@ -38,17 +39,25 @@ getShellEnv = ( path, timeout = 1000 ) ->
marker = "--- 8< ---"

# Script that will be passed as stdin to the shell
shellScript = [
# Change directory or exit
# NB: some tools (eg. RVM) can redefine "cd" command to execute some code
"cd #{shellEscape path} || exit -1",

# Print env inside markers
"echo '#{marker}' && env && echo '#{marker}'",

# Exit shell
"exit"
]
shellScripts =
bash: [
# Change directory or exit
# NB: some tools (eg. RVM) can redefine "cd" command to execute some code
"cd #{shellEscape path} || exit -1",

# Print env inside markers
"echo '#{marker}' && env && echo '#{marker}'",

# Exit shell
"exit"
],
fish: [
"cd #{shellEscape path}; or exit -1",
"echo '#{marker}'; and env; and echo '#{marker}'",
"exit"
]
# Script that will be passed as stdin to the shell, defaults to bash syntax
shellScript = if shellName of shellScripts then shellScripts[shellName] else shellScripts['bash']

# Spawn shell process and execute script
# NB: we can't use "exec" because we need full-fledged login interactive shell
Expand Down