Timeline for Automatic transformation of newlines in shell variable assignment
Current License: CC BY-SA 3.0
24 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 13, 2017 at 12:36 | history | edited | CommunityBot | replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/ | |
| Feb 28, 2014 at 17:12 | comment | added | goldilocks | @StephaneChazelas : I know -- I refer to one of those in my answer here. What I meant was, is that your moniker for the operation? Evidently so, which is fine by me, I just wanted to make sure there is no point looking for other explications of it (by name) in shell docs, etc. | |
| Feb 28, 2014 at 16:53 | comment | added | Stéphane Chazelas | See unix.stackexchange.com/search?q=user%3A22565+split%2Bglob, or more specifically this answer to Why do I need to quote variable for if, but not for echo? (of which your question is almost a duplicate) | |
| Feb 28, 2014 at 16:07 | comment | added | goldilocks | @StephaneChazelas : Okay, so parsing of input vs. expansion of output? In that case I would still expect it to apply when the variable is assigned to. Is the "split+glob" operator real or just something you have used for explication? I can't find any reference to that anywhere else (see my answer here). | |
| Feb 28, 2014 at 16:03 | vote | accept | goldilocks | ||
| Feb 28, 2014 at 16:01 | answer | added | goldilocks | timeline score: 0 | |
| Feb 28, 2014 at 15:36 | comment | added | Stéphane Chazelas | You're quoting a section about shell parsing, that's different from what the shell does upon variable expansion (the split+glob operator) | |
| Feb 28, 2014 at 15:25 | answer | added | Hauke Laging | timeline score: 3 | |
| Feb 28, 2014 at 15:21 | answer | added | X Tian | timeline score: 2 | |
| Feb 28, 2014 at 15:20 | comment | added | Graeme | @Stephane, good tip, thanks. Thought you would have the definitive answer for this... | |
| Feb 28, 2014 at 15:12 | comment | added | Stéphane Chazelas | @Graeme, sed -n l is better that cat -A as it's non-ambiguous (and is standard/portable). With cat -A, if you see ^M, you don't know if it's a CR character or the two characters ^ and M or ^ followed by a meta character. | |
| Feb 28, 2014 at 15:12 | comment | added | goldilocks | @fedorqui : Okay, but why would backslash-newline be transformed to backslash-space when unquoted? 2.2.1 from there actually states that "A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>. If a <newline> follows the <backslash>, the shell shall interpret this as line continuation. The <backslash> and <newline> shall be removed...the escaped <newline> is removed entirely" but clearly that is not at all what is happening. The escaped newline is being replaced by an "escaped" space character. | |
| Feb 28, 2014 at 15:10 | history | edited | terdon♦ | CC BY-SA 3.0 | forgot the quotes |
| Feb 28, 2014 at 15:03 | comment | added | fedorqui | OK I found a reference. See Shell command language - 2.2.3 Double-Quotes --> "Enclosing characters in double-quotes ( "" ) shall preserve the literal value of all characters within the double-quotes, with the exception of the characters backquote, <dollar-sign>, and <backslash>". | |
| Feb 28, 2014 at 15:00 | history | edited | goldilocks | CC BY-SA 3.0 | added 114 characters in body |
| Feb 28, 2014 at 14:56 | comment | added | goldilocks | @fedorqui : Right, my "last paragraph" was actually a little confused on that -- of course it isn't really a "further interpolation". Did not know about this aspect of quotes vs. non-quotes, tho. Do you know of anywhere that stipulates all the transformations that occur? | |
| Feb 28, 2014 at 14:52 | comment | added | fedorqui | In general, quoting while echoing is important to keep the original format. Hence, you have to trust the quoted echo when working with some text. | |
| Feb 28, 2014 at 14:50 | comment | added | goldilocks | @fedorqui : Interesting, since that seems to be a further interpolation -- I've added a last paragraph about this. | |
| Feb 28, 2014 at 14:49 | answer | added | Graeme | timeline score: 7 | |
| Feb 28, 2014 at 14:49 | history | edited | goldilocks | CC BY-SA 3.0 | added 323 characters in body |
| Feb 28, 2014 at 14:48 | answer | added | glenn jackman | timeline score: 2 | |
| Feb 28, 2014 at 14:45 | comment | added | Graeme | If find cat -A a good intermediate for looking at this kind of thing before going to hexdump or the like. Eg echo 6^6^3 | bc | cat -A. | |
| Feb 28, 2014 at 14:42 | comment | added | fedorqui | If you quote when echoing, it shows new lines but with trailing slash: echo "$num". | |
| Feb 28, 2014 at 14:39 | history | asked | goldilocks | CC BY-SA 3.0 |