Repository: mikefarah/yq (Go)

Issue:
Can't write a string value with a white space
**Describe the bug**
I can't write a string value containing a white space.

Version of yq: 4.0.0
Operating system: mac
Installed via: release/homebrew

**Command**
```
yq e -n '.test = "Hello world!"'
```

**Actual behavior**

```
Error: Parsing expression: Lexer error: could not match text starting at 1:9 failing at 1:16.
        unmatched text: "\"Hello "
```

**Expected behavior**

```yaml
test: Hello world!
```

**Additional context**
It works if there is no white space:
```
yq e -n '.test = "Hello-world!"'
```

Thanks for your help


Discussion:
I'm going to figure out why... Will be posting MR soon...
I mam trying to use yq and having zero success, 
including the exact symptom documented in this issue right here above.
..........................................

PS /> yq -V
yq version 4.3.2

PS /> yq e -n '.test = "Hello_world!"'
Error: Parsing expression: Lexer error: could not match text starting at 1:9 failing at 1:10.
        unmatched text: "H"


is that powershell? There's an issue raised here https://github.com/mikefarah/yq/issues/719 that I still need to look into...try using double quotes?
Thanks @mikefarah  the above was indeed PowerShell.
Touche!   It does work in bash.  :)  That is very clarifying.  Thanks a bunch for the pointer.
:) You win this round :) 

$ yq e -n '.test = "Hello_world!"'
test: Hello_world!


@mikefarah 

Here's powershell working right
PS > yq e -n '.test = ""something""'
test: something
PS >

Thanks again for your help
Hi , 

I am facing similar issues when using yq command in power shell.
Below is the command
PS > yq eval 'to_entries' sample.yaml
Error: Parsing expression: Lexer error: could not match text starting at 1:1 failing at 1:3.
        unmatched text: "to"

PS > cat sample.yaml
BU: local-market
@sdthameem, @mikefarah,

> I am facing similar issues when using yq command in power shell.
> Below is the command
> PS > yq eval 'to_entries' sample.yaml
> Error: Parsing expression: Lexer error: could not match text starting at 1:1 failing at 1:3.
> unmatched text: "to"

Hi, same here on Windows (Git Bash) in version 4.6.3 :
```sh
$ yq eval 'to_entries' pipeline.yaml
Error: Parsing expression: Lexer error: could not match text starting at 1:1 failing at 1:3.
        unmatched text: "to"
$ yq eval 'from_entries' pipeline.yaml
Error: Parsing expression: Lexer error: could not match text starting at 1:1 failing at 1:3.
        unmatched text: "fr"
```




yq Version 4.11.0

@ThibaultDelaune-pro
Working in Windows GitBash:
yq e -i '.test = "13137"' values.yaml

Subpath for example folder1/values.yaml not found though had to run it from values.yaml root.

Working in Powershell Windows:
yq e -i '.test = ""13137""' values.yaml

Subpaths are found, so you could call it form folder1/values.yaml
@sdthameem Pay attention on the double quote in Windows Powershell ""13137"" 

Now i'm trying to use yq and having zero success.
I want bypass output of kubectl command to yq. 

### How is look yaml input for yq
`kubectl get deployments -o custom-columns=IMAGE:. -o yaml` 
makes output:
```
apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Deployment
  <...>
```

### yq query 
`kubectl get deployments -o custom-columns=IMAGE:. -o yaml | yq 'items' -`

### Actual behavior
```
Error: parsing expression: Lexer error: could not match text starting at 1:1 failing at 1:3.
	unmatched text: "it"
```

### Expected behavior
Return spec node

yq 4.25.3 from the snap, Linux Ubuntu 20.04.1



Patch:
diff --git a/pkg/yqlib/path_tokeniser.go b/pkg/yqlib/path_tokeniser.go
index bcb7cc0224..59cfe4766b 100644
--- a/pkg/yqlib/path_tokeniser.go
+++ b/pkg/yqlib/path_tokeniser.go
@@ -250,7 +250,7 @@ func initLexer() (*lex.Lexer, error) {
 	lexer.Add([]byte(`[Nn][Uu][Ll][Ll]`), nullValue())
 	lexer.Add([]byte(`~`), nullValue())
 
-	lexer.Add([]byte(`"[^ "]*"`), stringValue(true))
+	lexer.Add([]byte(`"[^"]*"`), stringValue(true))
 
 	lexer.Add([]byte(`\[\]`), literalToken(SplatOrEmptyCollect, true))
 


Test patch:
diff --git a/pkg/yqlib/operator_assign_test.go b/pkg/yqlib/operator_assign_test.go
index 67eacc74a0..d548b86576 100644
--- a/pkg/yqlib/operator_assign_test.go
+++ b/pkg/yqlib/operator_assign_test.go
@@ -12,6 +12,13 @@ var assignOperatorScenarios = []expressionScenario{
 			"D0, P[], ()::a:\n    b: cat\nx: frog\n",
 		},
 	},
+	{
+		description: "Create yaml file with value with spaces",
+		expression:  `.a.b = "cat" | .x = "frog jumps"`,
+		expected: []string{
+			"D0, P[], ()::a:\n    b: cat\nx: frog jumps\n",
+		},
+	},
 	{
 		description: "Update node to be the child value",
 		document:    `{a: {b: {g: foof}}}`,