Re: [PATCH] [PARSER] Remove backslash before } in double-quotes in variable

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


On 21/11/10 14:41, Jilles Tjoelker wrote:
The backslash prevents the closing brace from terminating the
substitution, therefore it should be removed.

Thanks, that works great.

Example:
   printf "%s\n" ${$+\}} ${$+"\}"} "${$+\}}"
should print } three times, without backslashes.

Some tests with different a few shells:

                                                    "${$+'\}'}"
                                             "${$+"\}"}"
                                      "${$+\}}"
                               ${$+'\}'}
                        ${$+"\}"}
                 ${$+\}}

bash           | }      \}     \}     \}     }      '\}'
pdksh          | }      \}     \}     }      \}     \}
ksh            | }      }      \}     }      }      '}'
dash (current) | }      \}     \}     \}     \}     '\}'
dash (patched) | }      }      \}     }      }      '}'

The one thing that I was a bit confused about was the difference between ${$+'\}'} and ${$+"\}"}, but I do think that is correct: the backslash is used to see that the immediately following } is not a terminator, but the special rule allowing backslash before } to be removed in double-quoted strings in parameter expansions does not apply (there is no double-quoted string), so the backslash appears in the output as well. And since the last form uses a double-quoted string, the backslash gets removed there.

Cheers,
Harald
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

Powered by Linux