Skip to main content
Post Undeleted by Michael Homer
Post Deleted by Michael Homer
added 733 characters in body
Source Link
Michael Homer
  • 79k
  • 17
  • 221
  • 239

A character, say $, has a special meaning and is considered special when it has some impact other than being a literal part of data. In $x, $ has a special meaning introducing parameter expansion.

What this passage is saying is that the backslash has its escape-character meaning only when it precedes a one of these characters with a special meaning. Ordinarily, the backslash has broader escaping meaning:

A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>

For example, "\$x" is the string "$x", while "a\ b" is the string "a\ b", because the backslash in the second case precedes an unlisted character and so has no special meaning. Outside double quotes, however, a\ b is the string "a b", with the backslash causing the space to be included literally, and the backslash itself removed.

The passage you quoted isn't saying that sometimes the characters keep their special meaning despite being escaped, but rather that the backslash has no special meaning unless it would be impacting one of them.


There is a potential dangling modifier here: are the characters considered special, or the backslash?

There are some potential cases where some of those characters inside double quotes may not have a special meaning - most obviously within embedded expansions described in the immediately-preceding points to the one you quoted, but also in the delimiter of a here-document. Embedded expansions have their own quoting rules, however, as do here-document delimiters, so it's not clear to me that it can practically arise. If it's the backslash, all it says is that a double backslash doesn't escape anything.

The best case I have for where, if it is limiting the characters, it might come up is here-document delimiters:

cat <<"A$B"
A$B
cat <<"A\$B"
A$B

Both of those do the same thing on all my shells. Arguably the $ is not special, since it was included in the delimiter the first time, and so the \ inside double quotes should not have escaped it the second time and should have been literally included. You could make the case that this is a bug in bash, dash, posh, and zsh by the letter of the law, but I don't think it's clear that that this is required behaviour but it does seem consistent with the caseletter of the law.

For embedded expansions they either disavow any effect from the quotes (both kinds of $(...)) or have both their own quoting rules and no unique way to have something be quoted (all kinds of ${...} and ` ... `), and I haven't managed to construct something that clearly should have a non-special version of one of those characters and a non-special backslash before it.

I suspect the bolded text is currently redundant, though it doesn't hurt to be explicit, but it could still be clearer. RegardlessThe potential dangling modifier at the least makes it ambiguous, thereand perhaps this is no implication that any ofa phrasing bug to file for the listed characters might ever retain their special meaning when they look like they should be escapederrata or next update.

A character, say $, has a special meaning and is considered special when it has some impact other than being a literal part of data. In $x, $ has a special meaning introducing parameter expansion.

What this passage is saying is that the backslash has its escape-character meaning only when it precedes a one of these characters with a special meaning. Ordinarily, the backslash has broader escaping meaning:

A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>

For example, "\$x" is the string "$x", while "a\ b" is the string "a\ b", because the backslash in the second case precedes an unlisted character and so has no special meaning. Outside double quotes, however, a\ b is the string "a b", with the backslash causing the space to be included literally, and the backslash itself removed.

The passage you quoted isn't saying that sometimes the characters keep their special meaning despite being escaped, but rather that the backslash has no special meaning unless it would be impacting one of them.


There is a potential dangling modifier here: are the characters considered special, or the backslash?

There are some potential cases where some of those characters inside double quotes may not have a special meaning - most obviously within embedded expansions described in the immediately-preceding points to the one you quoted, but also in the delimiter of a here-document. Embedded expansions have their own quoting rules, however, as do here-document delimiters, so it's not clear to me that it can practically arise. If it's the backslash, all it says is that a double backslash doesn't escape anything.

The best case I have for where, if it is limiting the characters, it might come up is here-document delimiters:

cat <<"A$B"
A$B
cat <<"A\$B"
A$B

Both of those do the same thing on all my shells. Arguably the $ is not special, and so the \ inside double quotes should not have escaped it and should have been literally included. You could make the case that this is a bug in bash, dash, posh, and zsh by the letter of the law, but I don't think it's clear that that is the case.

For embedded expansions they either disavow any effect from the quotes (both kinds of $(...)) or have both their own quoting rules and no unique way to have something be quoted (all kinds of ${...} and ` ... `).

I suspect the bolded text is currently redundant, though it doesn't hurt to be explicit, but it could still be clearer. Regardless, there is no implication that any of the listed characters might ever retain their special meaning when they look like they should be escaped.

A character, say $, has a special meaning and is considered special when it has some impact other than being a literal part of data. In $x, $ has a special meaning introducing parameter expansion.

What this passage is saying is that the backslash has its escape-character meaning only when it precedes a one of these characters with a special meaning. Ordinarily, the backslash has broader escaping meaning:

A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>

For example, "\$x" is the string "$x", while "a\ b" is the string "a\ b", because the backslash in the second case precedes an unlisted character and so has no special meaning. Outside double quotes, however, a\ b is the string "a b", with the backslash causing the space to be included literally, and the backslash itself removed.

The passage you quoted isn't saying that sometimes the characters keep their special meaning despite being escaped, but rather that the backslash has no special meaning unless it would be impacting one of them.


There is a potential dangling modifier here: are the characters considered special, or the backslash?

There are some potential cases where some of those characters inside double quotes may not have a special meaning - most obviously within embedded expansions described in the immediately-preceding points to the one you quoted, but also in the delimiter of a here-document. Embedded expansions have their own quoting rules, however, as do here-document delimiters, so it's not clear to me that it can practically arise. If it's the backslash, all it says is that a double backslash doesn't escape anything.

The best case I have for where, if it is limiting the characters, it might come up is here-document delimiters:

cat <<"A$B"
A$B
cat <<"A\$B"
A$B

Both of those do the same thing on all my shells. Arguably the $ is not special, since it was included in the delimiter the first time, and so the \ inside double quotes should not have escaped it the second time and should have been literally included. I don't think it's clear that this is required behaviour but it does seem consistent with the letter of the law.

For embedded expansions they either disavow any effect from the quotes (both kinds of $(...)) or have both their own quoting rules and no unique way to have something be quoted (all kinds of ${...} and ` ... `), and I haven't managed to construct something that clearly should have a non-special version of one of those characters and a non-special backslash before it.

I suspect the bolded text is currently redundant. The potential dangling modifier at the least makes it ambiguous, and perhaps this is a phrasing bug to file for the errata or next update.

added 733 characters in body
Source Link
Michael Homer
  • 79k
  • 17
  • 221
  • 239

A character, say $, has a special meaning and is considered special when it has some impact other than being a literal part of data. In $x, $ has a special meaning introducing parameter expansion.

What this passage is saying is that the backslash has its escape-character meaning only when it precedes a one of these characters with a special meaning. Ordinarily, the backslash has broader escaping meaning:

A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>

For example, "\$x" is the string "$x", while "a\ b" is the string "a\ b", because the backslash in the second case precedes an unlisted character and so has no special meaning. Outside double quotes, however, a\ b is the string "a b", with the backslash causing the space to be included literally, and the backslash itself removed.

The passage you quoted isn't saying that sometimes the characters keep their special meaning despite being escaped, but rather that the backslash has no special meaning unless it would be impacting one of them.


There is a potential dangling modifier here: are the characters considered special, or the backslash?

There are some potential cases where some of those characters inside double quotes may not have a special meaning - most obviously within embedded expansions described in the immediately-preceding points to the one you quoted, but also in the delimiter of a here-document. Embedded expansions have their own quoting rules, however, as do here-document delimiters, so it's not clear to me that it can practically arise. If it's the backslash, all it says is that a double backslash doesn't escape anything.

The best case I have for where, if it is limiting the characters, it might come up is here-document delimiters:

cat <<"A$B"
A$B
cat <<"A\$B"
A$B

Both of those do the same thing on all my shells. Arguably the $ is not special, and so the \ inside double quotes should not have escaped it and should have been literally included. You could make the case that this is a bug in bash, dash, posh, and zsh by the letter of the law, but I don't think it's clear that that is the case.

For embedded expansions they either disavow any effect from the quotes (both kinds of $(...)) or have both their own quoting rules and no unique way to have something be quoted (all kinds of ${...} and ` ... `).

I suspect the bolded text is currently redundant, though it doesn't hurt to be explicit, but it could still be clearer. Regardless, there is no implication that any of the listed characters might ever retain their special meaning when they look like they should be escaped.

A character, say $, has a special meaning and is considered special when it has some impact other than being a literal part of data. In $x, $ has a special meaning introducing parameter expansion.

What this passage is saying is that the backslash has its escape-character meaning only when it precedes a one of these characters with a special meaning. Ordinarily, the backslash has broader escaping meaning:

A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>

For example, "\$x" is the string "$x", while "a\ b" is the string "a\ b", because the backslash in the second case precedes an unlisted character and so has no special meaning. Outside double quotes, however, a\ b is the string "a b", with the backslash causing the space to be included literally, and the backslash itself removed.

The passage you quoted isn't saying that sometimes the characters keep their special meaning despite being escaped, but rather that the backslash has no special meaning unless it would be impacting one of them.


There is a potential dangling modifier here: are the characters considered special, or the backslash?

There are some potential cases where some of those characters inside double quotes may not have a special meaning - most obviously within embedded expansions described in the immediately-preceding points to the one you quoted, but also in the delimiter of a here-document. Embedded expansions have their own quoting rules, however, as do here-document delimiters, so it's not clear to me that it can practically arise. If it's the backslash, all it says is that a double backslash doesn't escape anything.

I suspect the bolded text is currently redundant, though it doesn't hurt to be explicit, but it could still be clearer. Regardless, there is no implication that any of the listed characters might ever retain their special meaning when they look like they should be escaped.

A character, say $, has a special meaning and is considered special when it has some impact other than being a literal part of data. In $x, $ has a special meaning introducing parameter expansion.

What this passage is saying is that the backslash has its escape-character meaning only when it precedes a one of these characters with a special meaning. Ordinarily, the backslash has broader escaping meaning:

A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>

For example, "\$x" is the string "$x", while "a\ b" is the string "a\ b", because the backslash in the second case precedes an unlisted character and so has no special meaning. Outside double quotes, however, a\ b is the string "a b", with the backslash causing the space to be included literally, and the backslash itself removed.

The passage you quoted isn't saying that sometimes the characters keep their special meaning despite being escaped, but rather that the backslash has no special meaning unless it would be impacting one of them.


There is a potential dangling modifier here: are the characters considered special, or the backslash?

There are some potential cases where some of those characters inside double quotes may not have a special meaning - most obviously within embedded expansions described in the immediately-preceding points to the one you quoted, but also in the delimiter of a here-document. Embedded expansions have their own quoting rules, however, as do here-document delimiters, so it's not clear to me that it can practically arise. If it's the backslash, all it says is that a double backslash doesn't escape anything.

The best case I have for where, if it is limiting the characters, it might come up is here-document delimiters:

cat <<"A$B"
A$B
cat <<"A\$B"
A$B

Both of those do the same thing on all my shells. Arguably the $ is not special, and so the \ inside double quotes should not have escaped it and should have been literally included. You could make the case that this is a bug in bash, dash, posh, and zsh by the letter of the law, but I don't think it's clear that that is the case.

For embedded expansions they either disavow any effect from the quotes (both kinds of $(...)) or have both their own quoting rules and no unique way to have something be quoted (all kinds of ${...} and ` ... `).

I suspect the bolded text is currently redundant, though it doesn't hurt to be explicit, but it could still be clearer. Regardless, there is no implication that any of the listed characters might ever retain their special meaning when they look like they should be escaped.

Source Link
Michael Homer
  • 79k
  • 17
  • 221
  • 239

A character, say $, has a special meaning and is considered special when it has some impact other than being a literal part of data. In $x, $ has a special meaning introducing parameter expansion.

What this passage is saying is that the backslash has its escape-character meaning only when it precedes a one of these characters with a special meaning. Ordinarily, the backslash has broader escaping meaning:

A <backslash> that is not quoted shall preserve the literal value of the following character, with the exception of a <newline>

For example, "\$x" is the string "$x", while "a\ b" is the string "a\ b", because the backslash in the second case precedes an unlisted character and so has no special meaning. Outside double quotes, however, a\ b is the string "a b", with the backslash causing the space to be included literally, and the backslash itself removed.

The passage you quoted isn't saying that sometimes the characters keep their special meaning despite being escaped, but rather that the backslash has no special meaning unless it would be impacting one of them.


There is a potential dangling modifier here: are the characters considered special, or the backslash?

There are some potential cases where some of those characters inside double quotes may not have a special meaning - most obviously within embedded expansions described in the immediately-preceding points to the one you quoted, but also in the delimiter of a here-document. Embedded expansions have their own quoting rules, however, as do here-document delimiters, so it's not clear to me that it can practically arise. If it's the backslash, all it says is that a double backslash doesn't escape anything.

I suspect the bolded text is currently redundant, though it doesn't hurt to be explicit, but it could still be clearer. Regardless, there is no implication that any of the listed characters might ever retain their special meaning when they look like they should be escaped.