Comments (7)
Hey @jftuga. I actually looked at the lexer and changed my mind on this. It's trivial (a two-line change) and doesn't break any syntax or really hurt anything. So I added the fix and lexer and interp tests for it in 4ac40bb. Hope that helps!
from goawk.
Hmm, that's strange. Does the AWK (or mawk
) grammar actually change on Windows to support single quoted strings? When I try to use single-quoted strings in mawk on Unix (OS X), I get:
$ mawk "BEGIN { printf('foo') }"
mawk: 1: unexpected character '''
So it surprises me that this would work on Windows. Does your first example work for awk and gawk too? From what I've seen by Googling, folks use double quotes but escape them according to Windows shell rules.
from goawk.
It does not work with gawk 4.2.1.
c:\>dir c:\windows\system32 /s/a-d/-c | .\gawk.exe "{sum+=$4} END {printf('Total size: %.0f bytes, %3.2f (GB) for %1d files.\n', sum, (sum/1073741824.0), NR)}"
gawk: cmd. line:1: {sum+=$4} END {printf('Total size: %.0f bytes, %3.2f (GB) for %1d files.\n', sum, (sum/1073741824.0), NR)}
gawk: cmd. line:1: ^ invalid char ''' in expression
gawk: cmd. line:1: {sum+=$4} END {printf('Total size: %.0f bytes, %3.2f (GB) for %1d files.\n', sum, (sum/1073741824.0), NR)}
gawk: cmd. line:1: ^ syntax error
The ^ symbol is the escape character for Windows cmd-prompt, but escaping the double-quote still results in a syntax error...
gawk: cmd. line:1: {sum+=$4} END {printf(^Total
gawk: cmd. line:1: ^ syntax error
Even though single-quotes are not 'official', they still would be really nice to have under Windows.
from goawk.
A source for a working version of mawk for Windows is located here:
http://gnuwin32.sourceforge.net/packages/mawk.htm
Binaries | Zip | 96988 | 29 September 2005 | 0c499dacf47c513a8d9af4ec2abe94a7
from goawk.
I don't think I'm going to make this change, sorry. It's not per spec and I'd rather folks work around it on Windows using standard Windows escapes than change the syntax.
from goawk.
I made a patch for this:
https://gist.github.com/jftuga/840cc95139cd009621313ca30037e532
I copied the case statement for the double quotes in lexer.go and then changed the two instances of:
from '"' to '\'':
from goawk.
Thank you for making this change. I really appreciate it.
from goawk.
Related Issues (20)
- Regular expression does not match multi-line string HOT 1
- Incompatibility of regular expression \b HOT 1
- Inconsistent FNR behavior with and without hyphen argument HOT 5
- FILENAME not set to hyphen when reading from stdin HOT 1
- Consider adding -Wexec option of mawk and gawk HOT 4
- Add Gawk built-in functions such as mktime and strftime HOT 5
- Should the output of `-d` option be 100% correct AWK code equivalent to the source? HOT 2
- Dynamically changing RS HOT 4
- Code coverage for GoAWK HOT 10
- Semicolon not allowed as terminator for normal pattern without action HOT 2
- Add logfmt support HOT 1
- Add JSON Lines support HOT 2
- Add some tests for the -d, -da, and -dt options
- Add optimization for a[1] -> a["1"]
- Should coverage profiles use relative filenames? HOT 2
- Deleting from array while looping HOT 2
- [Feature Request] Support case when end range pattern is not distinct from start pattern HOT 2
- Error parsing "cond && var=value" HOT 3
- Error parsing $++a
- Add support for 'nextfile'
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.