Open janw4ld opened 2 weeks ago
Thanks for the report and repro.
The ~problem here is that I cheated and tried to see if we could bite these off even though they are inside single-quoted strings (the underlying OSH parser isn't giving us a structured representation of what's in them).
I think the "right" fix here (probably for both issues) is likely to be for resholve to go ahead and try to run the string for quoted alias definitions back through OSH's parser by themselves so that we're able to lean on its understanding of the string's contents.
I'll try to find time this week to look into implementing something.
For context, part of the reason to see if we could get away with ~cheating here is that I'm trying to avoid leaning any harder on being able to directly drive internal parts of the OSH parser than absolutely necessary until resholve is migrated off of Python2. (Some paths through that transition may leave resholve without the ability to readily leverage those parser internals. Until we know one way or the other, I'm trying to minimize how many corners I paint us into...)
this issue builds onto #117 where parsing fails for aliases with
=
chars in them. after applying the patch shown in that issue, aliases that have=
anywhere except the first word are parsed correctly, but if env vars are being set for the alias's command(s) the env var definition is picked up as the command instead leading to unexpected failures in resolution.i wrote a repro of the issue at https://github.com/janw4ld/resholve-alias-env-vars-repro which uses the patch from #117 to parse
alias ssh_prod='cd $(AWS_REGION=us-east-1 echo $PWD)'
correctly, then error out onalias ls_use1='AWS_REGION=us-east-1 ls'
to run it: