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,…
The attraction for me is not about portability, it's about having a better language to write CMD script. Even when you know you have Python available sometimes you still need to glue things together with CMD.
A language that compiles to Bash and Windows Batch
101–110 of 148 posts
Re: A language that compiles to Bash and Windows Batch
#102Earlier quoted context omitted.
I love python, but python is not a shell, and it makes an absolutely awful shell replacement. Python is further from a good shell than bash is from being a decent programming language. Some scripts are good, I do use python for some kinds of shell scripts, but most of what I need bash for, python is not a good replacement at all.
Perl is probably still the best in its class of being a decent language while allowing close interaction with shell commands. If I really needed to write a sophisticated shell script (try to avoid that), I'd probably go for Perl.
from subprocess import check_output as sh
files = sh(['ls'])
print files
This has its limits but covers a lot of basic use-cases for the backtick. I think some people first see an alternate way of doing this in Python that's a lot more hairy, even if more flexible, but it doesn't have to be that way...Re: A language that compiles to Bash and Windows Batch
#103Weird that it doesn't seem to support basename (1) and dirname (1) and their Windows equivalents (e.g. %~dp0% ) Quite a few of my scripts need to find files relative to the location of the script, or compute the path to an output file by replacing the extension of an input file.
As I read it, it is mainly a language that intends to "unify" bash and batch, but basename(1) is not so much a part of bash, but of POSIX, that is an executable in a POSIX environment, that can be called via bash. However it does say "Batsh provided some "built-in" functions that will compile to platform-dependent code.". Arguably you could count basename and dirname under that.
Re: A language that compiles to Bash and Windows Batch
#104Earlier quoted context omitted.
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?
Why would you need to install batsh?
Re: A language that compiles to Bash and Windows Batch
#105Earlier 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.
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 wo…
Re: A language that compiles to Bash and Windows Batch
#106Earlier 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.
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 wo…
Re: A language that compiles to Bash and Windows Batch
#107The 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,…
Some years ago, I was making a project that many parts of the build process depended on simple file copies (that this can do right) and ImageMagik calls (that are the same in all OSes)
I ended having to keep writing the same scripts over and over again in Batch and Bash, it was quite a pain to maintain, and it was obvious that there had to be some way to do it automatically (port one to the other, or generate both).
This software has my situation as the perfect use case, when you need to script command line tools that exist in both platforms.
Re: A language that compiles to Bash and Windows Batch
#108And anyway I have been already been using crossplatform .fsx scripts for quite some time. KTHXBYE
Re: A language that compiles to Bash and Windows Batch
#109Earlier quoted context omitted.
The attraction for me is not about portability, it's about having a better language to write CMD script. Even when you know you have Python available sometimes you still need to glue things together with CMD.
> 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...
Re: A language that compiles to Bash and Windows Batch
#110Earlier quoted context omitted.
The attraction for me is not about portability, it's about having a better language to write CMD script. Even when you know you have Python available sometimes you still need to glue things together with CMD.
These days you probably want Windows Powershell. It's built on the .NET framework so it's pretty darn powerful and AFAIK is available by default on every modern WinOS.