Snap set digits as string

I want to set a snap var to a string that consists only of lots of digits, which seems impossible:

knitzsche@pi3dev:~$ sudo snap set wifi-connect junk=“1234567890”
knitzsche@pi3dev:~$ sudo snap get wifi-connect junk
1.23456789e+09

Is it possible?

Hi @kyleN, try this:

ubuntu@ubuntu-xenial:/var/lib/snapd$ sudo snap set core junk=\"1234567890\"
ubuntu@ubuntu-xenial:/var/lib/snapd$ sudo snap get core junk
1234567890

@pstolowski I find the scientific representation surprising in this context. I know why it’s happening, but I think we should fix it so it doesn’t happen in our case. It’s easy to tell whether a number is an integer or not, and how large its representation would be.

Good point, I didn’t really think of it as I focused on the original problem. I’ll look into the issue of int representation, looks weird indeed.

1 Like

Yes this works:

me@pi3dev:~$ sudo snap set core junk=“1234567890”
me@pi3dev:~$ sudo snap get core junk
1234567890

Where is/should this be documented?

Cheers

We should improve the help text in snap set itself, and we also need to implement a few improvements to how it works as described here.

@pstolowski This was already fixed and released, right? Can you provide an update here, and if sensible drop the tracking tags from the topic?

It actually only landed on 23/08 and will be included in release 2.28.