Live data from Hacker News

A language that compiles to Bash and Windows Batch

github.com

91–100 of 148 posts

Re: A language that compiles to Bash and Windows Batch

#91
post #24

Earlier quoted context omitted.

It's significantly better than batch

Well sure, but these days PowerShell is what Windows people use for anything non-trivial.

Until your enterprise security people have a fit at something like PowerSploit [1] existing and turn on AllSigned via Group Policy. Then it's pretty much impossible to use PowerShell - edit, sign, test, edit, sign is quite painful with the current tooling (and that's even if you're "trusted" enough to get the codesigning cert). Not to mention that some of the scripts that Visual Studio uses aren't signed!

1: https://github.com/PowerShellMafia/PowerSploit

Re: A language that compiles to Bash and Windows Batch

#92

Isn't it ironic to write this tool in a language that is not available on Windows[1]? [1] "Windows support is comming soon. " https://ocaml.org/docs/install.html

OCaml is available on top of MinGW or Cygwin. The thing that isn't supported is OPAM (the package manager), and that's only for official support -- if you compile with MinGW or Cygwin you can get it working well enough for most tasks. You can actually get the compiler binaries from a precompiled versoin of the official distribution[1] or from a user-maintained distribution[2]. Additionally, you could just compile everything from source but that's more complex.

[1] https://protz.github.io/ocaml-installer/

[2] https://www.typerex.org/ocpwin.html

Re: A language that compiles to Bash and Windows Batch

#93
post #74

Earlier quoted context omitted.

> sometimes you still need to glue things together with CMD why? is there something cmd can do that python can't? one example is enough...

I don't use windows much anymore so there might be a better way to do this, but I'll propose a use case: Automating the installation of python on a fresh machine.

How are you going to install batsh though?

Re: A language that compiles to Bash and Windows Batch

#95
post #93

Earlier quoted context omitted.

I don't use windows much anymore so there might be a better way to do this, but I'll propose a use case: Automating the installation of python on a fresh machine.

How are you going to install batsh though?

you don't need to install batsh. you maintain your code in batsh, compile to bat and have that up on your page as a download.

Re: A language that compiles to Bash and Windows Batch

#96
post #74

Earlier quoted context omitted.

> sometimes you still need to glue things together with CMD why? is there something cmd can do that python can't? one example is enough...

It's not about can or can't I think. Examples: Language runtime can't be installed, system locked down with deepfreeze, not enough permissions..

Then how will batsh get installed?

Re: A language that compiles to Bash and Windows Batch

#97
post #74

Earlier quoted context omitted.

> sometimes you still need to glue things together with CMD why? is there something cmd can do that python can't? one example is enough...

I don't use windows much anymore so there might be a better way to do this, but I'll propose a use case: Automating the installation of python on a fresh machine.

Fresh machine where and for whom? I doubt a simple batch script will get you very far (setup.exe exists for a reason...), and I doubly-doubt you would have enough overlap in the process that something that can convert the steps to bash would be an advantage. The only advantage I see for batsh is that it looks nicer to write in for the tiny subset of batch it supports. But then so is pretty much anything else -- it wouldn't surprise me if someone has already written a DSL in a well known language that can output to batch or powershell, we don't need a whole new language for this.

Re: A language that compiles to Bash and Windows Batch

#99
post #80

I am the author of Batsh. Batsh is a toy language I developed 2.5 years ago in a hackathon. It was just for me to play with OCaml. Feel free to play with it at http://batsh.org/ .

This deserves to be called out in the readme, if for nothing else than to limit the wild threads on display here and maybe head off some future wild threads.

Re: A language that compiles to Bash and Windows Batch

#100

The idea is interesting, but ultimately the utility of this seems limited. The differences between windows and Unix are more than just the shell language involved; shell scripts are typically deeply intertwined with the system in question, to the point where it's often not the case that a bash script will even run reliably across different Unix systems, much less on windows. Also, you can already run bash on windows,…

I think it's a limitation more on the windows batch end. As mentioned, it's tricky for historical reasons. Powershell would be closer to Bash, functionally speaking. An adapter between the two would be more functional- however doesn't satisfy the point of batsh, which assumes cleanish-builds of the OS in question.

Powershell introduces more complications, with functions like Invoke-WebRequest being given the alias "curl". At a minimum, you would get a type validation error, as Invoke-WebRequest by default gives back headers and other data as objects inside a larger object, not just the content string that curl.exe defaults to returning.

This should work in both bash and PS, with different results:

  > curl HTTP://example.com > file.html
Post reply on HN