sqitchers / docker-sqitch

Docker Image packaging for Sqitch
MIT License
35 stars 39 forks source link

Powershell environment variables not properly picked up (Windows) #64

Open NeroVanbiervliet opened 2 weeks ago

NeroVanbiervliet commented 2 weeks ago

On one of our machine we use Windows + Powershell. We are trying to set SQITCH_USERNAME in the environment, but it is not properly picked up:

> $Env:SQITCH_USERNAME = "sensitiveusername"
> sqitch status dev

SQITCH_USERNAME is defined as sensitiveusername
 -e SQITCH_ORIG_SYSUSER="hilge" -e SQITCH_ORIG_EMAIL="hilge@LAPTOP-B433" -e TZ="Romance Standard Time" -e LESS=-R -e sensitiveusername -e HOME="/home"

C:\Users\hilge\Projects\contracting>docker run -it --rm --network host     --mount "type=bind,src=C:\Users\hilge\Projects\contracting,dst=/repo"     --mount "type=bind,src=C:\Users\hilge,dst=/home"      -e SQITCH_ORIG_SYSUSER="hilge" -e SQITCH_ORIG_EMAIL="hilge@LAPTOP-B433" -e TZ="Romance Standard Time" -e LESS=-R -e sensitiveusername -e HOME="/home" sqitch/sqitch:latest status --target dev 

As you can see, the environment variable is passed down as -e sensitiveusername. This should be -e SQITCH_USERNAME=sensitiveusername instead.

Our workaround is the ugly:

> $Env:SQITCH_USERNAME = "SQITCH_USERNAME=sensitiveusername"
theory commented 2 weeks ago

It looks like you're using the batch file, yes? I don't know much about DOS and Powershell prompts, but perhaps it has a bug in how it interprets environment variables?

NeroVanbiervliet commented 2 weeks ago

Yes you were right! I found the bug on line 31:

-    SET passopt=!passopt! -e !%%i!
+   SET passopt=!passopt! -e %%i=!%%i!

Works on our machine, but someone more windows-savvy should probably have a look.

Should I make a PR?

theory commented 2 weeks ago

Yeah, that'd be great, thank you!