daniel-sc / bash-shell-to-bat-converter

Converter for bash shell scripts to windows batch files.
https://daniel-sc.github.io/bash-shell-to-bat-converter
MIT License
229 stars 45 forks source link

Cannot read property 'start' of undefined #16

Open ROMVoid95 opened 4 years ago

ROMVoid95 commented 4 years ago

Getting this error when running the command to convert, also, might be related to this. The online version in the README also shows this error when you input a sh script

D:\bash-shell-to-bat-converter>node lib/cli.js modrelease.sh
converting file: modrelease.sh ...
D:\bash-shell-to-bat-converter\node_modules\bash-parser\src\index.js:52
                throw new Error(err.stack || err.message);
                ^
Error: TypeError: Cannot read property 'start' of undefined
    at Object.start [as previousReducer] (D:\bash-shell-to-bat-converter\node_modules\bash-parser\src\modes\posix\tokenizer\reducers\start.js:72:28)
    at expansionStart (D:\bash-shell-to-bat-converter\node_modules\bash-parser\src\modes\posix\tokenizer\reducers\expansion-start.js:38:15)
    at tokenizer (D:\bash-shell-to-bat-converter\node_modules\bash-parser\src\modes\posix\tokenizer\index.js:193:13)
    at tokenizer.next (<anonymous>)
    at Object.next (D:\bash-shell-to-bat-converter\node_modules\iterable-lookahead\index.js:51:24)
    at Object.next (D:\bash-shell-to-bat-converter\node_modules\map-iterable\index.js:33:30)
    at filterIterator (D:\bash-shell-to-bat-converter\node_modules\filter-iterator\index.js:6:12)
    at filterIterator.next (<anonymous>)
    at Object.next (D:\bash-shell-to-bat-converter\node_modules\map-iterable\index.js:33:30)
    at Object.next (D:\bash-shell-to-bat-converter\node_modules\iterable-lookahead\index.js:51:24)
    at Object.parse [as default] (D:\bash-shell-to-bat-converter\node_modules\bash-parser\src\index.js:52:9)
    at Object.convertBashToWin (D:\bash-shell-to-bat-converter\lib\convert-bash.js:109:36)
    at Object.<anonymous> (D:\bash-shell-to-bat-converter\lib\cli.js:9:26)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

and the error on the web version

parse error: Error: TypeError: Cannot read property 'start' of undefined
    at Object.LVmx.e.exports [as previousReducer] (https://daniel-sc.github.io/bash-shell-to-bat-converter/main-es2015.4a0ff3e228c4ecb17a52.js:1:160063)
    at Ny03.e.exports (https://daniel-sc.github.io/bash-shell-to-bat-converter/main-es2015.4a0ff3e228c4ecb17a52.js:1:164780)
    at https://daniel-sc.github.io/bash-shell-to-bat-converter/main-es2015.4a0ff3e228c4ecb17a52.js:1:154032
    at Generator.next (<anonymous>)
    at Object.next (https://daniel-sc.github.io/bash-shell-to-bat-converter/main-es2015.4a0ff3e228c4ecb17a52.js:1:536129)
    at Object.next (https://daniel-sc.github.io/bash-shell-to-bat-converter/main-es2015.4a0ff3e228c4ecb17a52.js:1:172319)
    at e.exports (https://daniel-sc.github.io/bash-shell-to-bat-converter/main-es2015.4a0ff3e228c4ecb17a52.js:1:213785)
    at e.exports.next (<anonymous>)
    at Object.next (https://daniel-sc.github.io/bash-shell-to-bat-converter/main-es2015.4a0ff3e228c4ecb17a52.js:1:172319)
    at Object.next (https://daniel-sc.github.io/bash-shell-to-bat-converter/main-es2015.4a0ff3e228c4ecb17a52.js:1:536129)
daniel-sc commented 4 years ago

Hi @ROMVoid95 , could you share the input that is causing this issue?

ROMVoid95 commented 4 years ago

sure, https://haste.romvoid.dev/maquyikiba.awk

i was thinking, and maybe something with the script calling other scripts?? branchsuffix=$(cc-param branch-suffix)

daniel-sc commented 4 years ago

I think the following is causing the issue:

if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    echo "Execution stopped."
fi
ROMVoid95 commented 4 years ago

Yep thats it. removed the two sections of the script that had that and it worked. so its errored on

if [[ $REPLY =~ ^[Yy]$ ]] then
    # do stuff
fi