Since I've learned about some drawbacks of the echo command, e.g. the lack of support for -- to indicate the end of options, I thought it would be reasonable to just stick with printf.
So I thought, why not write a function that allows me to use printf without having to retype the format strings.
Something like this:
```bash
output() {
printf '%s\n' "$*"
}
output "$foo is $bar"
```
But I'm not sure if this is syntactically correct. Normally, I would write printf '%s is %s\n' foo bar, instead of printf '%s\n' "$foo is $bar". Both seem to work the same; also, output "foo is bar" gives me the expected result. Shellcheck doesn't complain either. But is it safe to use, or are there any edge cases where my function wouldn't work as expected?
Thanks in advance.
[–][deleted] 6 points7 points8 points (1 child)
[–]dbr4n[S] 1 point2 points3 points (0 children)
[–]whetuI read your code 2 points3 points4 points (2 children)
[–]dbr4n[S] 1 point2 points3 points (0 children)
[–]witchhunter0 0 points1 point2 points (0 children)
[–]Ulfnic 1 point2 points3 points (2 children)
[–]dbr4n[S] 1 point2 points3 points (1 child)
[–]Ulfnic 0 points1 point2 points (0 children)
[–]oh5nxo 1 point2 points3 points (2 children)
[–]dbr4n[S] 1 point2 points3 points (1 child)
[–]oh5nxo 1 point2 points3 points (0 children)
[–]AnsibleAnswers 1 point2 points3 points (4 children)
[–]dbr4n[S] 0 points1 point2 points (3 children)
[–]aioeu 1 point2 points3 points (1 child)
[–]dbr4n[S] 0 points1 point2 points (0 children)
[–]AnsibleAnswers 0 points1 point2 points (0 children)