Coder Social home page Coder Social logo

Comments (5)

mikebattista avatar mikebattista commented on July 17, 2024 1

I can get it working by embedding quotes inside the parameters like below.

> awk -F''', ''' '''{print $2}''' .\test.txt
awk: warning: escape sequence `\,' treated as plain `,'
awk: warning: escape sequence `\ ' treated as plain ` '
Age
25
30
22
35
28

You need the embedded quotes to make sure they're passed through as part of the parameter value inside WSL. Otherwise, PowerShell uses them to process the parameters but doesn't consider them part of the parameter itself.

from powershell-wsl-interop.

speed65 avatar speed65 commented on July 17, 2024

Thanks for taking a look @mikebattista

Please forgive me if is this sounds rude, but just know that I am not trying to be.

Humble question:
I thought the point of your module was to allow correct functionality of the special characters such as the ' and not have to do corrective embedding or as you say "unnatural embedding"

Here is a quote from the fourth bullet on your README
Arguments with special characters (e.g. regular expressions) are often misinterpreted without unnatural embedded quotes or escape sequences

Thank you,

This has been a great module from what I have seen so far!

from powershell-wsl-interop.

mikebattista avatar mikebattista commented on July 17, 2024

Are you able to run awk inside wsl without using the quotes? The way the module avoids embedded quotes in general is to escape the parameters when they are passed to WSL so they are interpreted correctly without the quotes.

If you need to pass quotes, then they'll need to be embedded. The first set of quotes are interpreted by PowerShell and not part of the arguments. And single vs. double quotes have different meanings so wrapping arguments that are passed to WSL would not always behave as expected.

from powershell-wsl-interop.

speed65 avatar speed65 commented on July 17, 2024

So here is what happened when I tried the 3 different combos of quotes, and finally, the correct way.

speed65@UAS2324401:~$ awk -F', ' {print $2} test.txt
awk: cmd. line:1: {print
awk: cmd. line:1:       ^ unexpected newline or end of string
speed65@UAS2324401:~$ awk -F', {print $2} test.txt
>
> ^C
speed65@UAS2324401:~$ awk -F, {print $2} test.txt
awk: cmd. line:1: {print
awk: cmd. line:1:       ^ unexpected newline or end of string
speed65@UAS2324401:~$ awk -F', ' '{print $2}' test.txt
Age
25
30
22
35
28

Is there any way to tell Powershell or the module to grab the literal string following "awk" only when a command starts with the keyword "awk" so that the single quotes will not be interpreted by Powershell?

For Powershell maybe a change in the profile to do so.
For your module, well that's your dept. You would have to tell me. ;)

Just thinking out loud here.

Thank you,

from powershell-wsl-interop.

mikebattista avatar mikebattista commented on July 17, 2024

I don't believe so and I certainly wouldn't want to hardcode a path just for "awk".

from powershell-wsl-interop.

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.