Tilde expansion in quotes

You can use "${user_defined_directory/#~/$HOME}" to replace a “~” at the beginning of the string with the current user’s home directory. Note that this won’t handle the ~username/subdir format, only a plain ~. If you need to handle the more complex versions, you’ll need to write a much more complex converter.

Leave a Comment