The -r is telling print not to do something it normally does. The result is the raw string (which I think is what -r stands for).% print -r $gggabc\n \n def\n \n ghi\n
Then you are creating in the shell's memory a string containing a literal newline character (one byte with value 10), which the shell then passes to print, which just echoes it verbatim, doing no translation on it whatsoever. Job done. The translation from \n to newline was done by the shell before print ever ran.print $'\n'
print '\n'
On 2024-04-14 07:15, Roman Perepelitsa wrote:
> On Sun, Apr 14, 2024 at 4:06 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>> % ggg=( 'abc\n' '\n' 'def\n' '\n' 'ghi\n' )
> There are no newlines in there.
% ggg=( ' abc\n' '\n' 'def\n' '\n' 'ghi\n' )
% print $ggg
abc
def
ghi
% typeset -p ggg
typeset -a ggg=( ' abc\n' '\n' 'def\n' '\n' 'ghi\n' )