Skip to content
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

nix-create-sandbox-rc generates bad shell code in the presence of exported shell functions #34

Closed
twhitehead opened this issue Aug 17, 2016 · 0 comments · Fixed by #35
Closed

Comments

@twhitehead
Copy link
Contributor

In the particular setup I'm working on, there is a bash exported function module which is tripping up the environment setup code

module () 
{ 
    eval `/usr/bin/modulecmd bash $*`
}
declare -fx module

It produces the following environment variable definition under printenv

BASH_FUNC_module()=() {  eval `/usr/bin/modulecmd bash $*`
}

Which gets translated into the nix-sandbox-rc-... file command

export BASH_FUNC_module()=\(\)\ \{\ \ eval\ \`/usr/bin/modulecmd\ bash\ \$\*\`'
'\}

Causing the shell to choke with the error message

/tmp/nix-sandbox-rc-26417EZN line 97 syntax error near unexpected token `('

One solution may be to have nix-create-sandbox-rc just capture and use the output of

declare -x
declare -fx

for the shell script instead of using printenv -0.

Cheers! -Tyson

twhitehead added a commit to twhitehead/nix-emacs that referenced this issue Aug 17, 2016
This closes nix-community#34 as it properly handles exported shell functions.
twhitehead added a commit to twhitehead/nix-emacs that referenced this issue Aug 18, 2016
This closes nix-community#34 as it properly handles exported shell functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant