magicant / yash

Yet another shell
http://magicant.github.io/yash/
GNU General Public License v2.0
330 stars 30 forks source link

Orphan trailing backslash in pattern #30

Open magicant opened 1 year ago

magicant commented 1 year ago

(Issue migrated from https://osdn.net/projects/yash/ticket/40752)

XCU 2.13.1 Patterns Matching a Single Character:

If a pattern ends with an unescaped backslash, it is unspecified whether the pattern does not match anything or the pattern is treated as invalid.

This means the pattern should not match with any word in bs='\\\'; case word in $bs) echo match; esac. In existing shells, however, one of \, \\ and \\\ matches.


Seems the future version of POSIX is going to say that the entire behavior is unspecified in such a case.

https://www.austingroupbugs.net/view.php?id=1234#c4564

If a pattern ends with an unescaped backslash, the behavior is unspecified.