help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Escape Character and NewLine


From: Fernando Basso
Subject: [Help-bash] Escape Character and NewLine
Date: Mon, 16 Sep 2019 16:16:51 -0300

I was reading this section about the Escape Character:

https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Escape-Character

I then tried two examples to test my (mis)understanding:

Example 1:
----
printf '%s\n' foo\
    bar
----

And running example 1 produces what I had expected:

----
bash dev.sh
foo
bar
----

However, if I try it in an assignment operation:

Example 2:
----
str=foo\
    bar
----

The output is:
----
bash dev.sh
dev.sh: line 5: bar: command not found
----

In example 2, isn't the backslash causing the \newline to be treated as a
line
continuation and being effectively ignored?

What is going on here?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]