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

fix: allow spaces in commands #778

Closed
wants to merge 1 commit into from
Closed

fix: allow spaces in commands #778

wants to merge 1 commit into from

Conversation

markrzen
Copy link

@markrzen markrzen commented Apr 13, 2024

Fixes #700

Allows for spaces to exist in commands.

const cmd = `echo hello: ${process.env.NAME}`
await $`${cmd}`

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to README are included in PR
  • Types updated

@@ -48,7 +48,7 @@ export function noquote(): string {
}

export function quote(arg: string) {
if (/^[a-z0-9/_.\-@:=]+$/i.test(arg) || arg === '') {
if (/^[a-z0-9/_.\-@:= ]+$/i.test(arg) || arg === '') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. quote should NOT allow space char.

@antonmedv
Copy link
Collaborator

Please read doc at https://google.github.io/zx/quotes

@antonmedv antonmedv closed this Apr 13, 2024
@@ -57,6 +57,7 @@ describe('util', () => {

test('quote()', () => {
assert.ok(quote('string') === 'string')
assert.ok(quote('this that') === 'this that')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quote('this that') MUST quote output with $.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonmedv I think I have come at a side effect of the real issue then. I will re-attempt one more time.

@@ -5,7 +5,7 @@

await $`cat package.json | grep name`

let branch = await $`git branch --show-current`
let { stdout: branch } = await $`git branch --show-current`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed this discrepancy in the documentation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. This is not a discrepancy. zx works this way.

@@ -57,6 +57,7 @@ describe('util', () => {

test('quote()', () => {
assert.ok(quote('string') === 'string')
assert.ok(quote('this that') === 'this that')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonmedv I think I have come at a side effect of the real issue then. I will re-attempt one more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants