> The double-quotes here are unnecessary and should be left out for > optimal compatibility. Note that this may require a temporary variable > if the expansion is in a context where word splitting is performed. > However, you are right that the double-quotes are permitted per POSIX. > > On the other hand, some double-quotes that are really necessary are > missing: > > my_str=swan; last_char=${my_str#"${my_str%?}"}; echo "${last_char}" > > The inner double-quotes force any wildcard characters in $my_str to be > taken literally. This is required to work correctly with the string > sw*n, for example. > > It also happens to work around dash's bugs, both the above version and a > version with the redundant quotes you like: > > my_str=swan; last_char="${my_str#"${my_str%?}"}"; echo "${last_char}" Thanks for the useful tips! > Fixing this requires a test suite. Without a test suite, any attempt to > fix something is likely to break something else. A bit worrying not to have regression tests, indeed. In any case, there are plenty of workarounds to this minor issue, even if not fixed there is a reference now for someone else who might wonder. Br, Todor -- 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