diff options
author | Mike Burns and Eric Collins <mike@mike-burns.com> | 2016-12-23 16:18:40 -0500 |
---|---|---|
committer | Mike Burns and Eric Collins <mike@mike-burns.com> | 2016-12-26 16:39:20 -0500 |
commit | 147a7b66554b2b13bcbf6fec1204e0cc0a1790bf (patch) | |
tree | 6539b10986afe5babef3decb2991cd5bb11ac08b /test | |
parent | 0651e4f5e0e71b57d6564f2f2887ab98f13f1995 (diff) |
Handle spaces in dotfile name
In mkrc, separate the list of files with newlines instead of spaces.
Change the `$IFS` when iterating to handle this.
We hand the file off to rcup, which encodes the file name by replacing
spaces with the bell character (`\a`).
rcup then sends the file name off to lsrc, which decodes the bell back
into a space.
The test makes sure an `a` character is in the filename, in case some
encoding goes wrong. We use tr(1) instead of sed(1) because tr(1)
handles `\a`.
Shoutout to Sublime Text 3 for forcing this issue.
Diffstat (limited to 'test')
-rw-r--r-- | test/lsrc-spaces.t | 8 | ||||
-rw-r--r-- | test/mkrc-spaces.t | 30 |
2 files changed, 38 insertions, 0 deletions
diff --git a/test/lsrc-spaces.t b/test/lsrc-spaces.t new file mode 100644 index 0000000..fa406e2 --- /dev/null +++ b/test/lsrc-spaces.t @@ -0,0 +1,8 @@ + $ . "$TESTDIR/helper.sh" + +Should handle dotfiles with spaces + + $ touch ".dotfiles/sublame text 3.config" + + $ lsrc + /*/.sublame text 3.config:/*/.dotfiles/sublame text 3.config (glob) diff --git a/test/mkrc-spaces.t b/test/mkrc-spaces.t new file mode 100644 index 0000000..ebf8d5d --- /dev/null +++ b/test/mkrc-spaces.t @@ -0,0 +1,30 @@ + $ . "$TESTDIR/helper.sh" + +Should handle dotfiles with spaces + + $ touch ".sublime text 3.config" .example + $ touch .some\ other.config + + $ mkrc ".sublime text 3.config" .example .some\ other.config + + $ assert_linked "$HOME/.sublime text 3.config" "$HOME/.dotfiles/sublime text 3.config" + > assert_linked "$HOME/.example" "$HOME/.dotfiles/example" + > assert_linked "$HOME/.some other.config" "$HOME/.dotfiles/some other.config" + +Should handle hostnamed dotfiles with spaces + + $ touch ".sublime text 4.config" .example2 + + $ mkrc -o ".sublime text 4.config" .example2 + + $ assert_linked "$HOME/.sublime text 4.config" "$HOME/.dotfiles/host-$(hostname)/sublime text 4.config" + > assert_linked "$HOME/.example2" "$HOME/.dotfiles/host-$(hostname)/example2" + +Should handle tagged dotfiles with spaces + + $ touch ".sublime text 5.config" .example3 + + $ mkrc -t whatever ".sublime text 5.config" .example3 + + $ assert_linked "$HOME/.sublime text 5.config" "$HOME/.dotfiles/tag-whatever/sublime text 5.config" + > assert_linked "$HOME/.example3" "$HOME/.dotfiles/tag-whatever/example3" |