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

Marc Weber marco-oweber at gmx.de
Wed Nov 19 17:20:15 CET 2008


On Fri, Oct 17, 2008 at 12:22:55AM +0200, Marc Weber wrote:
> I've spend a some time today debugging a mistake..
> I didn't see a syntax error within my phase :-(
I've done so again :-(
Do you mind me comitting this to stdenv-updates bracnh?

Marc

Index: pkgs/stdenv/generic/setup.sh
===================================================================
--- pkgs/stdenv/generic/setup.sh        (revision 13334)
+++ pkgs/stdenv/generic/setup.sh        (working copy)
@@ -66,6 +66,22 @@
 ######################################################################
 # Initialisation.
 
+
+# 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 eval "rubbish'" yet. That's bad. I spend some time overseen this cause
+# more than once. This eval replacement function checks by running the code and
+# then assigning an var. If the last step didn't take place you've got
+# something wrong. I've send a bug report. But I don't know when it will be fixed
+eval(){
+  e="$(type eval | { read; while read line; do echo $line; done })" # get a copy of this function
+  unset eval;  # unset this function to use default one
+  local evalSucc="failure"
+  eval "evalSucc=ok;""$1"
+  eval "$e"    # define this function again
+  [ $evalSucc = "failure" ] && return 1
+}
+
 set -e
 
 test -z $NIX_GCC && NIX_GCC=@gcc@



More information about the nix-dev mailing list