[Nix-dev] Re: eval $buildPhase and exit code in case of syntax error

Marc Weber marco-oweber at gmx.de
Thu Nov 20 11:07:40 CET 2008


> And anyway, there's a famous saying among schemers that I find apropos
> here as well: "`eval' is evil".  :-)

Yes, because I've spend much more than 3 hours because of this nasty
problem. And I never ever want to do that again.
It's not that complex. It just works without harming anyone.

Its the time to tell me wether I should change the comment or the code.
If no one complains I'll commit it (as well as the rewrite of nukeReferences)

# eval is used whenever you define a hook within the derivation.
# sh does only print error messages, but doesn't return non zero exit code
# on malicious sh codde such as eval "while" yet. That's bad. I've missed this
# error not looking at the build output more than once.
# This eval replacement function checks syntax by running the code, finally
# assigning a var. If the last step didn't take place you've got something
# wrong. I've send a bug report. I don't know when it will be fixed.
eval(){
  e="$(type eval | { read; while read line; do echo $line; done })"
  unset eval;
  local evalSucc="failure"
  eval "evalSucc=ok;""$1"
  eval "$e"
  [ $evalSucc = "failure" ] && { echo "eval failed, snippet:"; echo "$1"; return 1; }
}

Sincerly

Marc Weber



More information about the nix-dev mailing list