I'll definitely be using this but I'd suggest replacing print with println.
I'll definitely be using this but I'd suggest replacing print with println.
It's supposed to be usable "inline", so it shouldn't print a newline. (E.g. `touch note-$(tu yesterday).md`)
Some terminals have an option to still write the $ prompt to the next line and use an enter symbol (⏎) to signify that no newline was printed.
It's not command substitution but the contentes in $variables will be expanded and splitted so you need to quote them or the newlines will get lost.
$ touch asdd
$ foo=$(echo -e '\n\nboop\n*dd\n'); echo $foo "$foo"
boop asdd
boop
*dd
Try create files with new lines and globbing in them, and forget to use quotes around filenames. Chaos ensues.> The shell shall expand the command substitution by executing command in a subshell environment (see Shell Execution Environment) and replacing the command substitution (the text of command plus the enclosing "$()" or backquotes) with the standard output of the command, removing sequences of one or more <newline> characters at the end of the substitution. Embedded <newline> characters before the end of the output shall not be removed; however, they may be treated as field delimiters and eliminated during field splitting, depending on the value of IFS and quoting that is in effect. If the output contains any null bytes, the behavior is unspecified.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
I don't know of any shell that doesn't follow that.