Comments (14)
Interesting -- that Gawk port must have a special-case handling for /dev/stderr
on Windows, because otherwise I'm not sure how that would work. I'm not sure I want to add special cases like this to GoAWK.
One idea I had for a workaround was using type
(the Windows equivalent of cat
) with "redirect stdout to stderr" operators, like this:
C:\> echo test | goawk "{print $0 > 'type 1>&2' }"
Would that work? (I don't have handy access to a Windows machine.)
from goawk.
Thank you, no, type
commnand in windows is an cmd internal command that does not read from stdin. Even if it could work (more
is a suitable command for this task), the structure of the command implies the creation of a separate process for each line being written, something that is a expensive task in windows.
Output to stderr
is a usual operation in awk scripts. To use it in windows we need a way to reference this stream, if not by adding a special case handling for the /dev/stderr
stream, maybe enabling an alternate way to reference the stderr
stream.
from goawk.
the structure of the command implies the creation of a separate process for each line being written, something that is a expensive task in windows.
Yes, that's true if you did it using >
. However, if you pipe it using |
, a single process will be started and the command will stay running as it converts output from stdout to stderr. But yeah, that won't work if type
does not read from stdin. You might be able to use findstr
, or perhaps Get-Content
if you're using Powershell.
But I'll keep this open to think further about adding /dev/stderr
support on Windows.
from goawk.
Dear @benhoyt, whatever you do, please refrain from following @golang lead in terms of cutting off Windows 7 users. It would be ridiculous if the well-known awk ports that have served us for decades continue to work, but your tool stops working.
from goawk.
Hi @sergeevabc, I'm afraid that ship has passed, as v1.25.0 is built with Go 1.21 (in general, I use the latest version to build, so I'm probably going to build the next version with Go 1.22). However, two things:
- It's easy to download the source and build yourself with Go 1.20. Just
git clone
it and then typego build
(with Go 1.20 installed). - I'm not opposed to a change to
scripts/make_binaries.sh
(which is what I use for building the release binaries) that builds 32- and 64-bit versions for Windows 7 as well. It should probably usego1.20.13
(the latest 1.20.x release) to do so. If you'd like that, please put up a PR.
Alternatively, you can keep using goawk v1.24.0, which is built with Go 1.20.6, so should work fine on Windows 7.
from goawk.
@benhoyt, goawk 1.25 works fine on my end (Windows 7 x64), hmm. Apparently, I was misled about the compilation peculiarities after Golang's speech on dropping Windows 7 support. Anyway, please keep in mind there are dedicated users of that OS here and there is not a single feature in awk that requires a new OS. It is not for Microsoft or another American hegemon to decide what is outdated and what is not β a good hammer continues to hammer nails even when its manufacturer has ceased to exist. I canβt imagine that C developers would come up with such betrayal, geez.
from goawk.
@naalmlqpele Sorry for the delay. Does #225 work for you on Windows? It seems to work fine on Windows in CI, but I don't actually have a Windows machine handy to test it more thoroughly.
from goawk.
@benhoyt Trying to compile in windows to test it, but I get redeclared errors in several blocks. Is there any place from where to get the binary with the changes included to test?
from goawk.
Here's a GOOS=windows GOARCH=amd64 go build -ldflags="-w"
build of this branch:
goawk-devstderr-windows-amd64.zip
from goawk.
@benhoyt , thank you for the build. Tested against multiple existing gnu awk scripts and several at hoc tests and working fine as expected without any problem. This includes outputs to stderr from print
and printf
, with and without ANSI escape sequences, with and without redirection to a file.
Any additional test you could think of, please, tell me.
from goawk.
No, that's good enough for me -- thanks! I've merged #225.
from goawk.
1.26.0 works fine on Windows 7, 1.27.0 throws an error as follows
$ goawk127.exe
Exception 0xc0000005 0x8 0x0 0x0
PC=0x0
runtime.asmstdcall(0xc0)
/home/ben/sdk/go1.22.2/src/runtime/sys_windows_amd64.s:75 +0x7a fp=0x22fc80 sp=0x22fc60 pc=0x47621a
rax 0x0
rbx 0x6e90d8
rcx 0x76f7c8
rdx 0x20
rdi 0x7fffffdd000
rsi 0x22fe78
rbp 0x22fdc0
rsp 0x22fc58
r8 0x0
r9 0x22fee8
r10 0x88a2e8
r11 0xc000004000
r12 0x22fec8
r13 0xc000004008
r14 0x6e8760
r15 0x0
rip 0x0
rflags 0x10293
cs 0x33
fs 0x53
gs 0x2b
from goawk.
@sergeevabc I build the released GoAWK binaries using the latest version of Go (Go 1.22 for GoAWK 1.27.0). The binaries are provided as a help to most folks, but it's easy to build yourself from source using Go 1.20 (which is the last version that fully officially supports Windows 7).
from goawk.
@benhoyt There is a way to provide Windows 7 compatible builds via Github as @schollz did with his Croc.
from goawk.
Related Issues (20)
- Missing support for json input files HOT 1
- CSV - loss of double quote when dataset is updated HOT 2
- After Go 1.21 is out, build with PGO enabled HOT 1
- close() on pipe command does not return exit status HOT 2
- close() on input pipe does not cleanup child process HOT 5
- system() always returns -1 if process exits due to signal
- fflush() stops on first flush error HOT 2
- Add support for new \u Unicode escape sequence
- Windows error: flag provided but not defined: -encodedCommand HOT 3
- goawk CSV mode ignores specified field separator HOT 2
- Allow line break between `}` and `while` HOT 1
- parser: Discriminate between constant and dynamic regexps HOT 3
- Support for network? HOT 3
- What's the purpose of `testdata/echo` HOT 7
- {} behaves like 1, END{} doesn't exhaust input HOT 2
- Support for %i in format strings. HOT 4
- srand() initialization without an argument. HOT 3
- Test failures on Linux/i386 HOT 4
- Misleading Error When Header Name Used in BEGIN/END HOT 4
- Goawk have problems with fields containing double quotes that are not used to delimit string HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goawk.