- 1 year ago
How do I run a command with spaces in a github workflow
Comment
1 / 1
To run a command with spaces in a GitHub workflow, you need to ensure that the command is properly quoted or escaped to preserve the spaces. Here are a few approaches you can use:
Enclose the command in double quotes:
- Wrap the command in double quotes to preserve the spaces. For example:yaml
- name: Run command with spaces
run: "echo Hello World"
- Wrap the command in double quotes to preserve the spaces. For example:
Use backslashes to escape the spaces:
- Use backslashes (
\
) to escape the spaces within the command. For example:yaml- name: Run command with spaces
run: echo\ Hello\ World
- Use backslashes (
Split the command into separate arguments:
- Instead of providing the entire command as a single string, split it into separate arguments. This is especially useful if you're passing the command as a list of arguments. For example:yaml
- name: Run command with spaces
run:
- echo
- Hello World
- Instead of providing the entire command as a single string, split it into separate arguments. This is especially useful if you're passing the command as a list of arguments. For example:
Choose the approach that suits your specific use case and ensure that the spaces in the command are preserved by proper quoting or escaping.