-
-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to add a quoted numeric key (which is not a number despite its appearance) #1247
Comments
You need to modify the 'tag' of the key node to force it to be a string:
|
or for your example: |
There are a number of issues with the "!!str" in bash. As the numeric key is generated via variable, the command string needs to be put in double quotes and the !! is interfering with the shell itself. There seems to be no way around this: your suggestions only work with single quoted commands. I still think that more straightforward approaches make software more usable. Results from my second and third example, IMHO, make no sense at all: I put some quoting in a key and it either gets ignored altogether or mangled (triple quotes as the result of single quoting!). But this is just MHO. |
Not even this works:
Your suggestion only works with static strings in single quotes. Variables are not expanded within single-quoted strings but are withing double-quoted ones. |
Yeah - there's a I highly recommend using single quotes for the expression, and these operators - otherwise you quickly end up in different quoting hells depending on your shell. That said, when I tried out |
Ok next release you will be able to:
as well as:
|
Just released the fix in v4.25.3 - let me know how it goes! |
Cool! Great idea! Will wait for the build in ArchLinux and test it. |
Weird results in ArchLinux:
and
Second example makes sense, first one none at all as I get the quotes around a numeric key anyway. I think this could break come backward compatibility. |
Hmm that was unintended...but I don't think it's necessarily incorrect. Hopefully won't cause anyone issues with backwards compatibility :| |
No way to add a quoted numeric key (which is not a number despite its appearance) as in:
yq -i '.Something.4242."Name" = "myID"' file.yaml
produces
yq -i '.Something."4242"."Name" = "myID"' file.yaml
produces
yq -i ".Something.'4242'."Name" = "myID"" file.yaml
produces
Version of yq: 4.25.2
Operating system: ArchLinux x86_64
Installed via: repository (community/go-yq 4.25.2-1)
The text was updated successfully, but these errors were encountered: