cortesi / modd

A flexible developer tool that runs processes and responds to filesystem changes
MIT License
2.8k stars 128 forks source link

modd crashes when specifying trailing backslash in daemon without piece of command on the new line #93

Closed kajojify closed 3 years ago

kajojify commented 3 years ago

How to reproduce:

  1. Let's consider such modd daemon:
    web/webpack.config.js {
    daemon: cd web; ./node_modules/.bin/webpack-dev-server \
        --port 8080 \
        --hot \
        --output-public-path "/" \
        --history-api-fallback
    }
  2. Put backslashe right after --history-api-fallback and go to the new line like this:
    
    web/webpack.config.js {
    daemon: cd web; ./node_modules/.bin/webpack-dev-server \
        --port 8080 \
        --hot \
        --output-public-path "/" \
        --history-api-fallback \

}

3. Run modd.

You will see such traceback in the logs:

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]: mvdan.cc/sh/expand.(Config).wordFields(0xc00014c500, 0xc00015e4a0, 0x1, 0x1, 0xc00012c120, 0x16, 0x0, 0x0, 0x0) /home/kajoj/go/pkg/mod/mvdan.cc/sh@v2.6.4+incompatible/expand/expand.go:488 +0x1254 mvdan.cc/sh/expand.Fields(0xc00014c500, 0xc00015c240, 0x8, 0x8, 0xc000126400, 0x2, 0x2, 0xc000149798, 0x630dc8) /home/kajoj/go/pkg/mod/mvdan.cc/sh@v2.6.4+incompatible/expand/expand.go:323 +0x19a mvdan.cc/sh/interp.(Runner).fields(0xc000106780, 0xc00015c240, 0x8, 0x8, 0xc000126400, 0x2, 0x2) /home/kajoj/go/pkg/mod/mvdan.cc/sh@v2.6.4+incompatible/interp/interp.go:134 +0x5a mvdan.cc/sh/interp.(Runner).cmd(0xc000106780, 0x72b840, 0xc00015c280, 0x72a680, 0xc000168ad0) /home/kajoj/go/pkg/mod/mvdan.cc/sh@v2.6.4+incompatible/interp/interp.go:715 +0x122d mvdan.cc/sh/interp.(Runner).stmtSync(0xc000106780, 0x72b840, 0xc00015c280, 0xc00016a058) /home/kajoj/go/pkg/mod/mvdan.cc/sh@v2.6.4+incompatible/interp/interp.go:654 +0x2d7 mvdan.cc/sh/interp.(Runner).stmt(0xc000106780, 0x72b840, 0xc00015c280, 0xc00016a058) /home/kajoj/go/pkg/mod/mvdan.cc/sh@v2.6.4+incompatible/interp/interp.go:635 +0x1ce mvdan.cc/sh/interp.(Runner).stmts(0xc000106780, 0x72b840, 0xc00015c280, 0xc000141000, 0x2, 0x4, 0x0, 0x0, 0x0) /home/kajoj/go/pkg/mod/mvdan.cc/sh@v2.6.4+incompatible/interp/interp.go:970 +0x65 mvdan.cc/sh/interp.(*Runner).Run(0xc000106780, 0x72b840, 0xc00015c280, 0x728360, 0xc00015c200, 0x0, 0xc000116f30) /home/kajoj/go/pkg/mod/mvdan.cc/sh@v2.6.4+incompatible/interp/interp.go:583 +0x34f main.main() /home/kajoj/go/pkg/mod/github.com/cortesi/modd@v0.0.0-20200630120222-8983974e5450/cmd/modd/main.go:81 +0x8c3 exited: exit status 2



modd version: 0.8
OS: Ubuntu 18.04
cortesi commented 3 years ago

Issue reported upstream at mvdan/sh#669.

cortesi commented 3 years ago

We're now pinned to sh master, so this should be fixed.