After further testing, it turns out the fix in @28924 does not work.
This improves on that change by removing the quotes entirely rather
than moving the '~' character outside the quotes. This actually
does work reliably across Linux variants, and still avoids using the
HOME variable which. HOME isn't 100% guaranteed to be set, while the
~ (tilde) always works in bash, by definition (when not interfered
with by quotes).