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

unable to use ( or ) when calling powershell #1635

Open
hahn-kev opened this issue May 6, 2024 · 0 comments
Open

unable to use ( or ) when calling powershell #1635

hahn-kev opened this issue May 6, 2024 · 0 comments
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@hahn-kev
Copy link

hahn-kev commented May 6, 2024

Simple task defined like this:

cmd: powershell if (test-path {{.HG_REPO_DIR}}/sena-4) { rm -r {{.HG_REPO_DIR}}/sena-4 }

however when I try to run it I get this error:

task: Failed to run task "setup-win": 1:15: a command can only contain words and redirects; encountered (

So I tried various ways of escaping the (, the last one being this:

vars: 
  TEST: "(test-path {{.HG_REPO_DIR}}/sena-4)"
cmds:
  - cmd: powershell if {{.TEST}} { rm -r {{.HG_REPO_DIR}}/sena-4 }

using task --dry shows this:

task: [setup-win] powershell if (test-path ./hgweb/repos/sena-4) { rm -r ./hgweb/repos/sena-4 }

which is exactly what I want, but then when I try to run it I get the same error again

task: [setup-win] powershell if (test-path ./hgweb/repos/sena-4) { rm -r ./hgweb/repos/sena-4 }
task: Failed to run task "setup-win": 1:15: a command can only contain words and redirects; encountered (

The only related issue I found was not helpful. It said this was an escaping issue, and ended with the user changing the syntax of their command, however I can't change the syntax powershell expects, it must be if ( test ) for an if block.

  • Task version: 3.36
  • Operating system: windows
  • Experiments enabled: none
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

No branches or pull requests

2 participants