nfischer / shelljs-transpiler

:shell: Easily transpile Bash to ShellJS
https://nfischer.github.io/shelljs-transpiler/
MIT License
74 stars 8 forks source link

Cannot parse config.guess/config.sub #33

Open khmseu opened 6 years ago

khmseu commented 6 years ago

Symptoms:

Unable to parse script Unable to identify parsing failure (please include your full script in the bug report) Please file a bug report at https://github.com/nfischer/shelljs-transpiler

Tested with versions /usr/share/misc/config.guess:timestamp='2013-06-10' /usr/share/misc/config.sub:timestamp='2013-08-10' and config.guess:timestamp='2018-01-11' config.sub:timestamp='2018-01-11'

Current versions can be found at: http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD

khmseu commented 6 years ago

It looks like the first line to break sh2js is

me=`echo "$0" | sed -e 's,.*/,,'`
nfischer commented 6 years ago

Yeah, that doesn't surprise me. ShellJS doesn't have great sed support (it only implements the s/ mode). The most reasonable fix would be for the transpiler to detect this and to fallback to shell.exec('sed ...') for non-s/ commands.

PRs are welcome, but I probably won't get to fixing this myself for a while.


The transpiler is far from complete, so we can't actually handle a script as complex as the ones you've linked to.