Comments (5)
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.
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.
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.
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.
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)
- Commands are not saved HOT 2
- Error loading profile HOT 6
- Wsl Default Paramter Error HOT 15
- Completion not working for default shells other than bash HOT 26
- PowerShell passes trimmed command to bash completion. HOT 7
- \\wsl$\<distro_name>\<path> UNC path syntax is not converted HOT 3
- Piping to less doesn't work with WSL2 distro HOT 11
- Cannot run npm/nvm HOT 16
- Bash Completion for python based commands (Ansible) HOT 8
- Make WslDefaultParameterValues dynamic not static HOT 3
- Argument completion only works for the first command in a pipeline
- wsl.exe ls is super slow (is this due to vmIdleTimeout=60 seconds) HOT 1
- -exec Parameter for "find" does not work properly HOT 2
- Command execution broken in Powershell 7.3.0 HOT 6
- `zsh:1: permission denied:` HOT 6
- Is there a way to export aliases from WSL2, so I can use them in PowerShell? HOT 2
- Feature Request: Ability to define bash functions that can be used either in the shell or PowerShell profile. HOT 1
- Install-Module WslInterop makes profile loading very slow HOT 1
- Importing WSL Bash aliases to Powershell
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 powershell-wsl-interop.