stowsh
stowsh copied to clipboard
Add link to hstow
Hello,
Thanks for this script. I recently implemented something similar, except it truly has no dependencies other than POSIX sh. Perhaps you'd consider adding a link to my script to the README?
https://git.spwhitton.name/dotfiles/tree/bin/hstow
Looks great! I'm pretty close to archiving stowsh as I find shell pretty much unmaintanable, and I'm happy to see someone else working on this use case!
Couple of questions:
- why do you link the package to a directory under
~/.STOW
, and then link to that link? Why the indirection? Why not just link to the package? - assuming there's a good reason for the previous question, would you consider changing
~/.STOW
to something more consistent with the XDG spec, e.g.~/local/share/stow
? - I couldn't get
unstow
to work:
$ ./hstow stow package/
$ ./hstow unstow package/
cut: [-bcf] list: values may not include zero
* why do you link the package to a directory under `~/.STOW`, and then link to that link? Why the indirection? Why not just link to the package?
I was previously using a wrapper for GNU Stow, written by the GNU Stow maintainer, which arranged things this way. By using the same scheme I don't have to try to migrate my symlinks on all the hosts I've got my dotfiles checked out on. Independently, I like how it makes it easy to identify the symlinks created by hstow, and means the unstow() routine can be simple.
* assuming there's a good reason for the previous question, would you consider changing `~/.STOW` to something more consistent with the XDG spec, e.g. `~/local/share/stow`?
It's unfortunate an XDG-compatible location wasn't chosen originally. But unfortunately I can't change it now without losing the two advantages noted above.
* I couldn't get `unstow` to work:
$ ./hstow stow package/ $ ./hstow unstow package/ cut: [-bcf] list: values may not include zero
Strange, can you 'set -x' for more info, please?
$ ./hstow unstow package/
++ printf '\n\t'
+ IFS='
'
+ export LC_ALL=C
+ LC_ALL=C
++ printf '\t'
+ tab=' '
++ printf '*[\001-\037\177]*'
+ cchars='*[-]*'
+ command -v readlink
+ '[' 2 = 2 ']'
+ '[' -d package/ ']'
++ cd package/
++ pwd
+ DIR=/Users/mike/tmp/package
++ echo /Users/mike/tmp/package
+++ echo /Users/mike
+++ wc -c
++ cut -c-11
+ '[' /Users/mike = /Users/mike ']'
++ echo /Users/mike/tmp/package
++ tr / _
+ NAME=_Users_mike_tmp_package
+ always_adopt=false
+ case "$1" in
+ unstow
+ cd /Users/mike
++ echo /Users/mike/tmp/package
+++ echo /Users/mike
+++ wc -c
++ cut '-c 12-'
cut: [-bcf] list: values may not include zero
+ dir_pat='^./'
Hello,
Thanks. Does it fix it if you replace the dir_pat line with this:
dir_pat="^.$(echo $DIR | cut -c$(echo $HOME | wc -m | tr -d ' ')-)/"
-- Sean Whitton
$ ./hstow unstow package/
++ printf '\n\t'
+ IFS='
'
+ export LC_ALL=C
+ LC_ALL=C
++ printf '\t'
+ tab=' '
++ printf '*[\001-\037\177]*'
+ cchars='*[-]*'
+ command -v readlink
+ '[' 2 = 2 ']'
+ '[' -d package/ ']'
++ cd package/
++ pwd
+ DIR=/Users/mike/tmp/package
++ echo /Users/mike/tmp/package
+++ echo /Users/mike
+++ wc -c
++ cut -c-11
+ '[' /Users/mike = /Users/mike ']'
++ echo /Users/mike/tmp/package
++ tr / _
+ NAME=_Users_mike_tmp_package
+ always_adopt=false
+ case "$1" in
+ unstow
+ cd /Users/mike
++ echo /Users/mike/tmp/package
+++ echo /Users/mike
+++ wc -m
+++ tr -d ' '
++ cut -c12-
+ dir_pat='^./tmp/package/'
++ find . -type l '!' -name . '!' -name '*[-]*'
++ grep -v '^./tmp/package/'
... and then nothing. The process is stuck. No output and I have to ctrl-c to get back a prompt.
Hello Mike,
Thank you for your reply. It confirms my previous fix is correct, at least, even if you have now stumbled upon another problem. I'm afraid I have no idea why it would get stuck there, and I don't have access to an OS X machine myself to look into it further. If you do figure it out, please let me know.
-- Sean Whitton