Skip to content

aliases with env vars preceding their definition aren't parsed correctly #118

@kasimeka

Description

@kasimeka

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 on alias ls_use1='AWS_REGION=us-east-1 ls'

to run it:

$ nix run github:janw4ld/resholve-alias-env-vars-repro
error: builder for '/nix/store/69fdc3gmqk0skji2pvv61hmsqc3xfawy-ls-us-east-1-0.1.0.drv' failed with exit code 3;
       last 16 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/d9wfgplcixl4z277gbpyr1pgy1c3dy80-ls-us-east-1-unresholved-0.1.0
       > source root is ls-us-east-1-unresholved-0.1.0
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: installPhase
       > Running phase: fixupPhase
       > [resholve context] : invoking resholve with PWD=/nix/store/l0zacr1n30jclfj3b66sm9m469f2djf9-ls-us-east-1-0.1.0
       > [resholve context] RESHOLVE_LORE=/nix/store/075jskrlr77rvh2952zfpxxy5kghjvx8-more-binlore
       > [resholve context] RESHOLVE_FIX=aliases
       > [resholve context] RESHOLVE_INPUTS=
       > [resholve context] RESHOLVE_INTERPRETER=/nix/store/k56w4s2vav93hir7lsfw0qkqd97qvqkr-bash-interactive-5.2p32/bin/bash
       > [resholve context] /nix/store/h63slfwa931hcb66h8xgcpk9cp161h9g-resholve-0.10.5/bin/resholve --overwrite bin/ls-us-east-1
       >   alias ls_use1='AWS_REGION=us-east-1 ls'
       >         ^~~~~~~~
       > /nix/store/l0zacr1n30jclfj3b66sm9m469f2djf9-ls-us-east-1-0.1.0/bin/ls-us-east-1:9: Couldn't resolve command 'AWS_REGION=us-east-1'
       For full logs, run 'nix-store -l /nix/store/69fdc3gmqk0skji2pvv61hmsqc3xfawy-ls-us-east-1-0.1.0.drv'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions