5 ms·
Glad you like it! =) 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 optio
by adius 2y ago
Glad you like it! =)
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.
- keybored 2y agoI’ve never had a problem in Bash with `$()` and newlines. All tools that I’ve used terminate their input with a newline. Is this a problem in other shells, perhaps?
- emj 2y agoUsing a linter is a good idea. 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.
- arp242 2y agoTrailing newlines are removed in backtick and $(..) substitution per POSIX: > 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/V3_chap02.html#tag_18_06_03 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V... I don't know of any shell that doesn't follow that.
- bobbylarrybobby 2y agoCan it check whether it's writing to a terminal? There are many programs that will write colorized output to a terminal but not colorized output to a file.