Add function to expand ~ in .stowrc files (#14)

Add a new expand_tilde() function that performs tilde expansion of
strings, and corresponding unit tests:

    * A ~ at the beginning of a path is expanded to the user's home
      directory.
    * Literal '~' can be provided with '\~'

Combine this with expand_environment() in a new expand_filepath()
function which applies all (both) required expansion functions to a
string, and use that in get_config_file_options() to expand .stowrc
options.

Add more tests to check that tilde expanded in correct places, i.e.:

    * expanded for --target and --dir
    * not expanded for --ignore, --defer, or --override

Update documentation on stowrc files according to this functionality
change.

Fixes #14: https://github.com/aspiers/stow/issues/14
This commit is contained in:
Charles LeDoux 2016-07-14 14:48:40 -05:00 committed by Adam Spiers
parent 9674738792
commit dc42c34107
4 changed files with 134 additions and 7 deletions

10
NEWS
View file

@ -22,6 +22,16 @@ News file for Stow.
Thanks to Joris Vankerschaver for this feature!
*** Shell-like expansion in .stowrc files
For options within .stowrc files which describe file paths, "~" can
be included to expand to the current value of $HOME, and
environment variables can be referenced e.g. via "$FOO" or
"${FOO}". To prevent expansion, escape with a backslash.
Thanks a lot to Charles LeDoux for his diligent work on this
feature!
*** chkstow now honours the $STOW_DIR environment variable
The stow script already honoured the $STOW_DIR environment