Skip to content
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

parsing aliases with = inside them fails with ValueError: too many values to unpack #117

Open
janw4ld opened this issue Oct 29, 2024 · 1 comment

Comments

@janw4ld
Copy link

janw4ld commented Oct 29, 2024

resholve fails to parse aliases with = chars in their definition because aliases are split with .split('=') here, this breaks derivation realisation whether or not solutions.default.fix.aliases is set to true.

example alias that triggers the issue:

ssh_prod='ssh $(AWS_REGION=us-east-1 ssm-machine jump)'

error emitted during evaluation:

>   File "/nix/store/bmnmsvgqamwdcvybicmw5hkv1lanihnh-resholve-0.10.5/bin/.resholve-wrapped", line 3509, in handle_builtin_alias
>     alias, definition = word.strip("\"='").split("=")
> ValueError: too many values to unpack

patching resholve as follows to only split on the first occurrence of = fixed it for me, I'm willing to create a PR for this if you don't mind.

diff --git a/resholve b/resholve
index c163fa9..e0581bc 100755
--- a/resholve
+++ b/resholve
@@ -3506,7 +3506,7 @@ class RecordCommandlike(object):
             if word.ok:
                 # not dynamic; more examples in tests/aliases.sh, but:
                 # 'd', 'echo $SOURCE_DATE_EPOCH'
-                alias, definition = word.strip("\"='").split("=")
+                alias, definition = word.strip("\"='").split("=", 1)
                 # TODO: maybe below deserves an explicit API
                 cmdlikes[alias].alias = True
                 commandlike = definition.split()[0]
@janw4ld janw4ld changed the title issue parsing aliases that contain = inside them parsing aliases with = inside them fails Oct 29, 2024
@janw4ld janw4ld changed the title parsing aliases with = inside them fails parsing aliases with = inside them fails with ValueError: too many values to unpack Oct 29, 2024
@abathur
Copy link
Owner

abathur commented Oct 29, 2024

Thanks for the patch and PR offer.

I think you can hold off on the PR for now while I see if I can turn around a more general fix for my own corner-cutting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants