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

Trim whitespace from run in tasks #3444

Closed
joshbode opened this issue Dec 10, 2024 · 2 comments · Fixed by #3450
Closed

Trim whitespace from run in tasks #3444

joshbode opened this issue Dec 10, 2024 · 2 comments · Fixed by #3450

Comments

@joshbode
Copy link
Contributor

joshbode commented Dec 10, 2024

If whitespace was trimmed (start and end of string) from the run field, then it would make it more convenient/readable to use multi-line scripts in tasks, e.g.

[tasks.test]
run = '''
printf 'args:\n'
printf '  - %s\n' "$@"
'''

which yields:

$ mise run test a b c
[test] $ printf 'args:\n'
args:
  -
sh: line 2: a: command not found
[test] ERROR task failed

note: If I put the first command on the first line, this does work but it's a bit harder to read:

[tasks.test]
run = '''printf 'args:\n'
printf '  - %s\n' "$@"'''

yielding:

$ mise run test a b 'c d'
[test] $ printf 'args:\n'
args:
  - a
  - b
  - c d

(also, only the first line of the command is shown, which is probably unnecessary)

@jdx
Copy link
Owner

jdx commented Dec 10, 2024

I'm surprised this wasn't happening already

@joshbode
Copy link
Contributor Author

joshbode commented Dec 10, 2024

It confused me for a while because the error from sh isn't entirely helpful/obvious :)

jdx added a commit that referenced this issue Dec 10, 2024
@jdx jdx closed this as completed in #3450 Dec 10, 2024
@jdx jdx closed this as completed in facc513 Dec 10, 2024
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 a pull request may close this issue.

2 participants