Giter Site home page Giter Site logo

Comments (7)

benhoyt avatar benhoyt commented on May 13, 2024 1

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.

benhoyt avatar benhoyt commented on May 13, 2024

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.

jftuga avatar jftuga commented on May 13, 2024

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.

jftuga avatar jftuga commented on May 13, 2024

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.

benhoyt avatar benhoyt commented on May 13, 2024

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.

jftuga avatar jftuga commented on May 13, 2024

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.

jftuga avatar jftuga commented on May 13, 2024

Thank you for making this change. I really appreciate it.

from goawk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.