Earlier quoted context omitted.
Agreed. Powershell has almost completely replaced batch scripts, and is actually a fairly pleasant language to work with.
As I said in the other threads, the language is great, the performance has been abysmal in relation to batch (at least for me, having started with Powershell in its first release in Vista).
Batsh – A language that compiles to Bash and Windows Batch
61–70 of 130 posts
Re: Batsh – A language that compiles to Bash and Windows Batch
#62Earlier quoted context omitted.
As I said in the other threads, the language is great, the performance has been abysmal in relation to batch (at least for me, having started with Powershell in its first release in Vista).
This eludes me but why care about the performance of a shell scripting language?
Re: Batsh – A language that compiles to Bash and Windows Batch
#63Earlier quoted context omitted.
This sounds like you're saying that it suits your needs, therefore we should take that as meaning it fits our needs. Unfortunately, things are not that simple. I needed to do something and looked at using powershell, but in the end I couldn't just distribute it and have it work for whomever would be using my project. It needed to be signed or something. On the contrary, the bat script I wrote just worked and would ju…
PS> Set-ExecutionPolicy Unrestricted It's the first line of just about every publicly-distributed script (including Chocolately, etc).
Re: Batsh – A language that compiles to Bash and Windows Batch
#64Re: Batsh – A language that compiles to Bash and Windows Batch
#65This is great for me. As part of my day job I am often stuck writing batch scripts (yes, in 2014) for clients that refuse to run powershell. Writing a simple batch script is usually not a problem, but it can be very encumbering as the complexity increases. Thank you for sharing.
Re: Batsh – A language that compiles to Bash and Windows Batch
#66Earlier quoted context omitted.
PS> Set-ExecutionPolicy Unrestricted It's the first line of just about every publicly-distributed script (including Chocolately, etc).
One of the reasons I'm still afraid to use Powershell - its just not succint enough for normal day to day operations.
Re: Batsh – A language that compiles to Bash and Windows Batch
#67I don't like the concept so much. They are their own languages, and I'd rather write very low level ansible primitives and build upon them than rely on a somewhat opaque translation process. Also, all automation I do going forward is PowerShell, not batch. I could see a lot of places using it, though, so bravo for sharing.
Exactly, when the automation need arises just Batsh it.
Re: Batsh – A language that compiles to Bash and Windows Batch
#68This implementation is not perfect, although it's interesting that it supports Windows. I personally don't care about that, but it brings the idea to create some sugary wrapper around Bash that allows you to use Bash v4 features such as associative arrays in Bash v3, and wrappers that allow functions to return arrays and other typical headaches.
My initial thought after seeing this is Windows support is interesting, but the real value is in making bash friendlier. Something that brings syntactic sugar to bash is welcome in my mind, as I always find myself putzing with Google to find solutions to even slightly non-trivial scripts. Perhaps I should just master bash scripting once and for all (I know it's not that complex), but I generally find it unpleasant to…
Most of the time I find myself struggling with Bash, it's because a simple script has kept expanding in scope and I'm well into the sunk-cost fallacy in trying to fix "just that one last thing".
But unless you have a really specific environment, I'm pretty sure most modern servers probably have Python or Ruby or some other stack that can be a shell script available. If you're in Bash, it's because you were trying to do something quickly.
Re: Batsh – A language that compiles to Bash and Windows Batch
#69Re: Batsh – A language that compiles to Bash and Windows Batch
#70Nice to see this compiler adopting some idioms that make it easier for working with larger codebases, e.g. passing a return value variable name into subroutines. The author apparently lacks a bit of understanding on how to write robust batch files, though. Turning
x = "a|b";
into set x=a|b
is surely going to cause trouble. Quoting the argument to set is also often much easier than correctly escaping every meta-character. And iterating over files by throwing for /f at dir's output will cause trouble with filenames that use characters outside the current legacy codepage (not to mention that /w is the wrong switch and /b must be used, otherwise you get funny "files" back like Volume, in, drive, C, ...). Testing their language and output for correct functioning apparently wasn't high on the list, or at least, as usual, only for bash.(Bugs reported, but the choice of implementation language makes pull requests a bit hard for me. It also seems that the language is unusable for anything but simple stuff. readdir() returns a string with space-separated file names, but there is no way of iterating over them again (and it's not easy in batch files). Things like iterating over arrays or better support for printing text that does not cause trouble or side-effects have been known for over half a year without a change. I guess the project, while nice, is currently a zombie.)
____
¹ Last thing I really wrote was a deployment script for a website that had to run on Server 2k3 instances where I wasn't allowed to install anything. And I still have a half-written bignum library in numerous batch files somewhere. Only addition worked properly, though.