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

Ludovic Courtès ludo at gnu.org
Wed Nov 19 18:08:20 CET 2008


Hello,

Marc Weber <marco-oweber at gmx.de> writes:

> +# 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
> +}
> +

Quoting the Bash manual (info "(bash) Bourne Shell Builtins"):

  `eval'
            eval [ARGUMENTS]
       The arguments are concatenated together into a single command,
       which is then read and executed, and its exit status returned as
       the exit status of `eval'.  If there are no arguments or only
       empty arguments, the return status is zero.

Doesn't it work as documented for you?

Thanks,
Ludo'.




More information about the nix-dev mailing list