Long ago I thought about writing something that compiles to batch files, if only to make complex logic a bit easier to write or make the process of thinking about every little syntactic idiosyncrasy less tedious. Since then I found PowerShell though, and the need of writing complex and sophisticated batch files isn't so much there anymore¹. Nice to see this compiler adopting some idioms that make it easier for workin…
The main issue with powershell is portability - no guarantee that someone's Windows box will have it installed or not. I recently wrote a batch script just to make sure it'd run on any Windows system rather than risk powershell. If it was always going to run in a controlled environment, I'd have written it in cygwin bash anyway.
Batsh – A language that compiles to Bash and Windows Batch
91–100 of 130 posts
Re: Batsh – A language that compiles to Bash and Windows Batch
#92This 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.
I want to agree, but my major gripe using the different incantantions of Powershell (and I have tried, I am Winboxen admin often in my job and tried it before any other co-worker on Vista, obviously the story has improved since) and the startup time and performance was abysmal. In terms of performance for very basic scripts (silent software installs, 5-10 lines, registry patching, etc.), I see the performance chart a…
Re: Batsh – A language that compiles to Bash and Windows Batch
#93http://sourceforge.net/projects/scriptconvert/
Much of the stuff there is half assed but there is some goodies. Like substring searching and dumping of stdout without using temporary files, which is insanely weird in batch definitely take a look.
Re: Batsh – A language that compiles to Bash and Windows Batch
#94Re: Batsh – A language that compiles to Bash and Windows Batch
#95Re: Batsh – A language that compiles to Bash and Windows Batch
#96Re: Batsh – A language that compiles to Bash and Windows Batch
#97Earlier quoted context omitted.
The main issue with powershell is portability - no guarantee that someone's Windows box will have it installed or not. I recently wrote a batch script just to make sure it'd run on any Windows system rather than risk powershell. If it was always going to run in a controlled environment, I'd have written it in cygwin bash anyway.
You have that guarantee starting with Windows 7. Version is one thing; some nice things are available only in v3+, but v2 is very usable already. Execution policy is another matter, but you can always supply a batch file with the PowerShell script containing powershell -ExecutionPolicy Bypass -NoProfile -File %~dp0.ps1 %* That's what I usually do, which is also helpful for colleagues who have no idea how to run a Pow…
I'm not going to walk a user through that when I can do what I want in batch (with more pain, but still less than ending up providing support...).
My normal area is Linux though, and both powershell and batch make me appreciate bash so much more. Even those little things like being able to format arbitrary dates as you want...
Re: Batsh – A language that compiles to Bash and Windows Batch
#98Earlier quoted context omitted.
You have that guarantee starting with Windows 7. Version is one thing; some nice things are available only in v3+, but v2 is very usable already. Execution policy is another matter, but you can always supply a batch file with the PowerShell script containing powershell -ExecutionPolicy Bypass -NoProfile -File %~dp0.ps1 %* That's what I usually do, which is also helpful for colleagues who have no idea how to run a Pow…
I thought powershell had to be explicitly installed/enabled even in win7. I'm not going to walk a user through that when I can do what I want in batch (with more pain, but still less than ending up providing support...). My normal area is Linux though, and both powershell and batch make me appreciate bash so much more. Even those little things like being able to format arbitrary dates as you want...
> Even those little things like being able to format arbitrary dates as you want...
You mean like
$someDate.ToString('yyyy-MM-dd')
'Today: {0:yyyy-MM-dd}' -f (Get-Date)
Get-Date -Format yyyy-MM-dd
date -f yyyy-MM-dd
Right, that's excruciatingly hard in PowerShell (hey, you even get Unix date format strings with Get-Date -UFormat). (But I guess we just come from different worlds here, as every time I have to read or write bash scripts it makes me appreciate PowerShell so much more.) Granted, the batch variant is ... not as pretty: for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate=%%x
echo Today: %MyDate:~0,4%-%MyDate:~4,2%-%MyDate:~6,2%
And I found the PowerShell script alongside with the batch file a pretty workable solution. Nicer language and still something for clueless users to double-click.Re: Batsh – A language that compiles to Bash and Windows Batch
#99I just use Python if I'm going to install something anyway.
Re: Batsh – A language that compiles to Bash and Windows Batch
#100Earlier quoted context omitted.
One of the reasons I'm still afraid to use Powershell - its just not succint enough for normal day to day operations.
Like all software it will be read far more often than it is written. It is optimised for that common use case.