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

Spaces and quotes aren't handled correctly by bun run #53

Closed
Tracked by #2450
KishanBagaria opened this issue Nov 4, 2021 · 5 comments · Fixed by #3290
Closed
Tracked by #2450

Spaces and quotes aren't handled correctly by bun run #53

KishanBagaria opened this issue Nov 4, 2021 · 5 comments · Fixed by #3290
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client

Comments

@KishanBagaria
Copy link
Contributor

KishanBagaria commented Nov 4, 2021

package.json:

{
  "scripts": {
    "argv": "node -e 'console.log(process.argv)'"
  }
}

Screenshot 2021-11-05 at 1 55 05 AM

@KishanBagaria KishanBagaria changed the title Spaces and quotes aren't handled correctly by bun Spaces and quotes aren't handled correctly by bun run Nov 4, 2021
@Jarred-Sumner
Copy link
Collaborator

working on a fix

@KishanBagaria
Copy link
Contributor Author

looks like it's not fully identical to npm behavior (i've to use \" instead of just "):

(this is fish)

@Jarred-Sumner Jarred-Sumner reopened this Nov 5, 2021
@kidonng
Copy link
Contributor

kidonng commented Jul 27, 2022

Not sure if the following issue is related:

bat -p package.json 
{
  "name": "blank",
  "version": "0.0.3",
  "module": "src/index.js",
  "scripts": {
    "demo": "echo \"test\""
  },
  "devDependencies": {
    "bun-types": "latest"
  }
}npm run demo

> blank@0.0.3 demo
> echo "test"

testbun run demo
$ echo \"test\"
"test"

Basically npm does JSON parsing but bun doesn't seem to do it.

@Electroid Electroid added the bug Something isn't working label Nov 1, 2022
@Electroid
Copy link
Contributor

Thanks for reproducing, @kidonng, confirmed it's still an issue as of 0.2.2. We'll get it fixed.

@Electroid Electroid added the bun install Something that relates to the npm-compatible client label Jan 18, 2023
@lutzissler
Copy link

Confirming this is still an issue with 0.5.9:

 "scripts": {
        "start": "bun run src/app.ts",
        "add:article": "curl -X POST -H 'Content-Type: application/json' -d '{\"id\":1,\"title\":\"Test article\",\"body\":\"Test body\"}' http://localhost:4000/articles/"
    }

Running this won’t work with Bun:

$ bun run add:article
$ curl -X POST -H 'Content-Type: application/json' -d '{\"id\":1,\"title\":\"Test article\",\"body\":\"Test body\"}' http://localhost:4000/articles/
{
  "title": "Bad Request",
  "status": 400,
  "detail": "Unable to parse JSON: JSON Parse error: Unrecognized token '\\'"
}

But it does with npm:

$ npm run add:article

> @ add:article
> curl -X POST -H 'Content-Type: application/json' -d '{"id":1,"title":"Test article","body":"Test body"}' http://localhost:4000/articles/

The reason is clearly that Bun doesn’t parse JSON as stated above.

alexlamsl added a commit to alexlamsl/bun that referenced this issue Jun 12, 2023
alexlamsl added a commit to alexlamsl/bun that referenced this issue Jun 12, 2023
alexlamsl added a commit to alexlamsl/bun that referenced this issue Jun 13, 2023
Jarred-Sumner pushed a commit that referenced this issue Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants