aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-04 19:05:07 +0800
committerobscuren <geffobscura@gmail.com>2014-07-04 19:05:07 +0800
commitd5bcc01eae2912528e8ab2a65733c84fa3f8f4e1 (patch)
tree1b0d69226dd52c894668a54048e2bd977648aca8 /ethutil
parent633027d980642c703f659eb5faaf13455a3477d3 (diff)
downloadgo-tangerine-d5bcc01eae2912528e8ab2a65733c84fa3f8f4e1.tar
go-tangerine-d5bcc01eae2912528e8ab2a65733c84fa3f8f4e1.tar.gz
go-tangerine-d5bcc01eae2912528e8ab2a65733c84fa3f8f4e1.tar.bz2
go-tangerine-d5bcc01eae2912528e8ab2a65733c84fa3f8f4e1.tar.lz
go-tangerine-d5bcc01eae2912528e8ab2a65733c84fa3f8f4e1.tar.xz
go-tangerine-d5bcc01eae2912528e8ab2a65733c84fa3f8f4e1.tar.zst
go-tangerine-d5bcc01eae2912528e8ab2a65733c84fa3f8f4e1.zip
Fixed shebang check. Previously it would hang on an unknown shebang
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/script.go44
1 files changed, 26 insertions, 18 deletions
diff --git a/ethutil/script.go b/ethutil/script.go
index af4ca6a38..aaa0f8ed8 100644
--- a/ethutil/script.go
+++ b/ethutil/script.go
@@ -10,28 +10,36 @@ import (
// General compile function
func Compile(script string) (ret []byte, err error) {
- c := strings.Split(script, "\n")[0]
+ if len(script) > 2 {
+ line := strings.Split(script, "\n")[0]
- if c == "#!serpent" {
- byteCode, err := serpent.Compile(script)
- if err != nil {
- return nil, err
- }
+ if line[0:2] == "#!" {
+ switch line {
+ case "#!serpent":
+ byteCode, err := serpent.Compile(script)
+ if err != nil {
+ return nil, err
+ }
+
+ return byteCode, nil
+ }
+ } else {
- return byteCode, nil
- } else {
- compiler := mutan.NewCompiler(backend.NewEthereumBackend())
- byteCode, errors := compiler.Compile(strings.NewReader(script))
- if len(errors) > 0 {
- var errs string
- for _, er := range errors {
- if er != nil {
- errs += er.Error()
+ compiler := mutan.NewCompiler(backend.NewEthereumBackend())
+ byteCode, errors := compiler.Compile(strings.NewReader(script))
+ if len(errors) > 0 {
+ var errs string
+ for _, er := range errors {
+ if er != nil {
+ errs += er.Error()
+ }
}
+ return nil, fmt.Errorf("%v", errs)
}
- return nil, fmt.Errorf("%v", errs)
- }
- return byteCode, nil
+ return byteCode, nil
+ }
}
+
+ return nil, nil
}