oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
72.09k stars 2.58k forks source link

`bun build --compile` does not escape slashes in environment variables #10470

Open Kusigeri opened 2 months ago

Kusigeri commented 2 months ago

What version of Bun is running?

1.1.4+fbe2fe0c3

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

Not correct reads environment variables properly after compiling.

/*  .env file:
FILE_PATH=C:\Program Files\nodejs\node.exe
FILE_PATH2=C:\Windows\win.ini
FILE_PATH3="C:\Windows\win.ini"
*/

// index.ts
const server = Bun.serve({ port: 3000, fetch(request) { return new Response("!"); },});
console.log(`Path : ${process.env.FILE_PATH} `);
console.log(`Path2 : ${process.env.FILE_PATH2} `);
console.log(`Path3 : ${process.env.FILE_PATH3} `);

/*      bun run ./index.ts      result:
Path : C:\Program Files\nodejs\node.exe 
Path2 : C:\Windows\win.ini
Path3 : C:\Windows\win.ini
*/

/*      bun build index.ts --compile --outfile ./build/index.exe    result:
Path : C:Program Files
odejs
ode.exe
Path2 : C:Windowswin.ini
Path3 : C:Windowswin.ini
*/

What is the expected behavior?

/*      bun build index.ts --compile --outfile ./build/index.exe    result:
Path : C:\Program Files\nodejs\node.exe 
Path2 : C:\Windows\win.ini
Path3 : C:\Windows\win.ini
*/

What do you see instead?

No response

Additional information

No response

lukasMega commented 2 weeks ago

I confirm. I can reproduce it on my windows machine:

output:

 .\dist\server.exe
Path : C:Program Files
odejs
ode.exe
Path2 : C:Windowswin.ini
Path3 : C:Windowswin.ini

system info:

 C:\neofetch.exe
                                ..,
                    ....,,:;+ccllll            lm@LM-MAXWELL
      ...,,+:;  cllllllllllllllllll            --------------
,cclllllllllll  lllllllllllllllllll            OS: Windows 10 Pro
llllllllllllll  lllllllllllllllllll            Build: 22H2 (19045)
llllllllllllll  lllllllllllllllllll            Uptime: 0 days, 6 hours, 7 minutes
llllllllllllll  lllllllllllllllllll            Resolution: 2560x1440 @60Hz
llllllllllllll  lllllllllllllllllll            Terminal: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
llllllllllllll  lllllllllllllllllll            CPU: AMD Ryzen 5 5600G with Radeon Graphics
                                               GPU: AMD Radeon(TM) Graphics
llllllllllllll  lllllllllllllllllll            Memory: 15563 MB / 32121 MB (48% in use)
llllllllllllll  lllllllllllllllllll            Disk: C:\ 102.42 GB (6.72 GB free)
llllllllllllll  lllllllllllllllllll
llllllllllllll  lllllllllllllllllll            Mem%:  -=[ /////////            ]=-
llllllllllllll  lllllllllllllllllll
llllllllllllll  lllllllllllllllllll            Disk%: -=[ //////////////////// ]=-
`'ccllllllllll  lllllllllllllllllll
      `' \\*::  :ccllllllllllllllll
                       ````''*::cll
                                 ``