summaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAge
* Fix #237Gravatar Mat M2020-08-28
| | | | | Fix $ sigil for lsrc -F Add test
* Fix shell globbing bugsGravatar Edd Salkield2020-04-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are several problems leading to the unintentional globbing issue: Firstly, within `rcup` and `rcdn`, when constructing arguments to pass to `lsrc`, the _for_ loops over the arguments do not have quoted variables, leading to globbing. I have quoted these accordingly. Secondly, `lsrc` is invoked as follows: ```sh dests_and_srcs="$(lsrc $LS_ARGS)" ``` When shells use command substitution like this, they go through two stages: - Word expansion. This is useful because it splits `LS_ARGS` back up into its constituent strings. - File name expansion. The side effect of this is to introduce globbing. You can read more about how this works [here](https://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html#sect_03_04_07). To fix this, I have passed `lsrc` and its arguments to `eval`. This involves quoting the relevant arguments, so: ```sh for dotfiles_dir in "$DOTFILES_DIRS"; do LS_ARGS="$LS_ARGS -d $dotfiles_dir" done ``` becomes ```sh for dotfiles_dir in "$DOTFILES_DIRS"; do LS_ARGS="$LS_ARGS -d \"$dotfiles_dir\"" done ``` Then `lsrc` is invoked as follows: ```sh dests_and_srcs="$(eval "lsrc $LS_ARGS")" ``` There is one final non-globbing issue: the parsing of arguments can introduce extra spaces in the variables, which then trip up the `dotfiles_dir_excludes` function. For example: ```sh I) includes="$includes $OPTARG";; ``` introduces a space if `includes` is empty or null. I have introduced the function `append_variable`, which allows two variables to be appended without introducing unnecessary whitespace. Then the additional whitespace is never added in the first place. Fixes #256.
* Do not symlink a symlink in mkrcGravatar Mat M2020-01-17
| | | | | | | | | | | | | | We have a bug when calling mkrc(1) on a symlink: ```sh mkrc ~/.vimrc # links ~/.vimrc to ~/.dotfiles/vimrc mkrc ~/.vimrc # deletes ~/.dotfiles/vimrc ``` This catches that case ahead of time, preventing the user from running mkrc(1) on a symlink. Fix #144.
* avoid cd having issues with paths that begin with -Gravatar Christian Höltje2018-07-06
|
* Expand ~ in DOTFILES_DIRSGravatar Rebecca Meritz2017-10-27
| | | | | Hat tip to fgatham for the `eval echo` tip. This means both `~` and e.g. `~dmr` work correctly.
* rcup: handle directory names containing whitespaceGravatar Florian Tham2017-03-10
| | | | This commit fixes #197.
* Fixes for the Debian Almquist Shell (dash)Gravatar Florian Tham2017-02-24
| | | | | | | | | | | The `[` command, which is a builtin for dash, does not understand the `==` operator; this should be `=` instead. While here, more quotes in more places, including around `$*`. `CONFIG_SHELL=/bin/dash ./configure && make check` reports no failed test. Closes #200.
* Handle spaces in dotfile nameGravatar Mike Burns and Eric Collins2016-12-26
| | | | | | | | | | | | | | | | | 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.
* Fix relative exclude globsGravatar Mike Burns and Eric Collins2016-12-26
| | | | | | | Pass the dotfiles subdir along with the file to `is_excluded` so that we can match against it. Preserve single-file compatibility by looping twice.
* Symlink identical files if they are not yet linkedGravatar Graham Bennett2015-11-27
| | | | | Edge case: a file is a copy of a dotfile but is not linked. In this case we should link it.
* rcdn(1) recurs until home dir, not rootGravatar Mike Burns2015-11-20
| | | | | | | | rcdn(1) will try to remove a file; if it is not a dotfile, it will keep going up until it found one. However, we should stop at `$DEST_DIR` (`$HOME`) -- nothing is relevant to us above there. Closes #169.
* Non-recursive MakefileGravatar Mike Burns2015-11-07
| | | | | Instead of a complex graph, process everything from one Makefile. Simplify, simplify.
* Do not depend on readlink(1) or -qGravatar Jarkko Kniivilä2015-11-01
| | | | | | | | | | | | | | | | | Solaris 10 lacks readlink(1). Additionally, its different grep(1) and diff(1) do not take a `-q` flag. Use a Perl one-liner instead of readlink(1) which is missing on Solaris 10. Also because /usr/bin/grep and diff(1) don't understand the `-q` option, make them go quiet by redirecting stdout to `/dev/null` instead. The Perl dependency only exists in the test suite, so it does not incur a runtime penalty for end users. This is to work around the fact that readlink(1) is missing on Solaris. The tradeoff is: on Solaris, installing third-party software (readlink) is a pain, whereas on e.g. FreeBSD installing third-party software (Perl) is simple and common.
* Changes the priority to: hosts->tags->defaultGravatar Christian Höltje2015-06-05
| | | | | | | | | | This changes the order that things are pulled in so that: 1. Hosts take priority over everything. 2. Tags take priority over default. 3. Default takes priority over nothing. Closes #94
* Run hooks on rcdn as indicated by the manpageGravatar Ben Turrubiates2015-01-07
| | | | | | - Make sure IFS in rcup and rcdn isn't left in an incorrect state when the output of lsrc is empty. - Add tests to check that hooks run on rcdn and rcup by default.
* Support rc files without leading dotsGravatar Christopher Koch2014-11-19
| | | | | | | | | | | This adds the `-U` option to lsrc(1), rcup(1), and rcdn(1) commands; its argument is an exclusion pattern. Any file matching this pattern is symlinked without the leading dot. There is also a `-u` option to undo a `-U`. The `UNDOTTED` setting in rcrc(5) can be used to set it permanently. The mkrc(1) command has `-U` and `-u` flags. They take no argument.
* Update usage messagesGravatar Mike Burns2014-11-14
| | | | | | | | Various flags were missing from usage messages across the system; `-g` and `-s` were the most notable ones. Add them to the appropriate usage messages. Spotted by Christopher Koch.
* Generate an installation scriptGravatar Mike Burns2014-08-26
| | | | | | | | | | | | | | | | | | This commit adds a `-g` flag to rcup(1) to generate a standalone shell script. This shell script can then be run again, even on different computers, to recreate the symlinks. This allows people to recreate the "download my dotfiles and run ./install.sh" instructions, but with generated code that they do not need to maintain. This provides us more freedom with lsrc(1): since rcm can be used to generate a universal shell script, lsrc(1) now can be harder to install -- it can depend on a compiler, for example -- because you only need to install it on one machine. The generated script is rather limited; this can be improved in future commits, as desired.
* Fix -I in rcdn(1)Gravatar Christopher Koch2014-07-29
| | | | | The prior fix for `-k` moved the `:` from after `I` to after `k`. Move it back.
* rcdn(1) -K -kGravatar Mike Burns2014-07-22
| | | | | | | | | The rcdn(1) program is all set up to handle the `-K` and `-k` flags, except those flags were never actually allowed through `getopts`. Thanks to Mikkel Fahnøe Jørgensen for discovering this. Closes #93.
* Allow the user to override SYMLINK_DIRS with -sGravatar Mike Burns2014-07-09
| | | | | | | | This adds a `-s` that can be used to override the `SYMLINK_DIRS` config, or the `-S` flag, to lsrc(1), mkrc(1), rcup(1), and rcdn(1). The `-s` flag is the opposite of -S: any argument, if it is a directory, is not symlinked but instead recurred down.
* On bad args, show usage and exitGravatar Mike Burns2014-05-30
| | | | | | | | | | | | The lsrc(1), mkrc(1), rcup(1), and rcdn(1) commands will now print a usage message and exit immediately (with 64, `EX_USAGE`) when given an option it does not understand. This includes `--version` and `--help`. Normal `-h` will print usage and exit successfully, as normal. Closes #59.
* Update documentation on usageGravatar Mike Burns2014-05-09
| | | | | | | | | | | | | | | | | New flags have accumulated without proper care for the usage instructions or man pages. I manually went through each program and verified its usage instruction against its `getopts`, then I alphabeticalized the usage message. Based on the usage message, I then verified the synposis in the manpage. Then, based on the synposis, I alphabeticalized the detailed listing of the arguments and filled in the missing pieces. The `-h` and `-V` arguments were missing from all manpages. In the future we will need to be more careful about this. It would be good to automate a checker that refuses to build unless the docs have all the flags mentioned.
* Add a hostname overrideGravatar Mike Burns2014-05-07
| | | | | | | | | | | | | | | | | | | Based on issue #82, we now provide `-B` to override the hostname. In particular: - `mkrc -B foo` will enable `-o` but with the hostname set up `foo`. - `lsrc -B foo` will work like normal `lsrc` except it treats `host-foo` as the host-specific directory. - `rcup -B foo` will run a normal `rcup` except `host-foo` is the host-specific directory. - `rcdn -B foo` is just like normal `rcdn`, but with `host-foo` as the host-specific directory. The `HOSTNAME` can also be set in the rcrc(5), and this is overridden by the aforementioned `-B`. While making this change: The `test/Makefile.am` used a mix of tabs and spaces. Since it's a Makefile, replace it all with tabs.
* Bugfix: do not break out of the for loopGravatar Mike Burns2014-05-06
| | | | | | | | A `break` anywhere inside a `for` loop (even inside a `case`) will exit from the innermost loop. Replace the `break` with a `:` to get the desired effect. Spotted by Pat Brisin.
* mkrc with relative filenames inside dotted dirGravatar Pablo Olmos de Aguilera Corradini2014-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | This is best explained with an example. If I want to track a file like `~/.bundle/config`, the correct way would be: ~$ mkrc ~/.bundle/config --> ~/.dotfiles/bundle/config But if you are already inside the directory, say: ~/.bundle $ and you ran: ~/.bundle $ mkrc con<TAB> # for autocomplete ~/.bundle $ mkrc config --> ~/.dotfiles/.config Which is obviously not what you meant. This basically checks first if the file exists in the current working directory and if it is, it's expand the full path. ~/.bundle $ mkrc config --> ~/.dotfiles/bundle/config
* Files with the same prefix in different dirsGravatar The Linux Kitten2014-04-01
| | | | | | | | | | | | | | | | | | | | The bug: ~% ls -1 test-dotfiles/**/*(.) test-dotfiles/tag-openbsdbox/zshrc_alias test-dotfiles/tag-openbsdbox/zshrc_bsd test-dotfiles/tag-zsh/zshrc ~% lsrc -t openbsdbox -t zsh -d test-dotfiles /home/mike/.zshrc_alias:/home/mike/test-dotfiles/tag-openbsdbox/zshrc_alias /home/mike/.zshrc_bsd:/home/mike/test-dotfiles/tag-openbsdbox/zshrc_bsd ~% We expect to also see: /home/mike/.zshrc:/home/mike/test-dotfiles/tag-zsh/zshrc This arises because we were checking for files the start with another name, rather than a full equality.
* Discover a POSIX shell for SolarisGravatar Mike Burns2014-03-28
| | | | | | | | | | | | Under Solaris, use ksh instead of `/bin/sh`. This uses `$SHELL` as a POSIX shell, coupled with a `configure` check that sets it correctly. Note that the POSIX shell might end up being bash, so this actually introduces more fragmentation than it reduces. Taken from https://github.com/freedreno/mesa/blob/master/configure.ac
* Add support for -v option on OpenBSDGravatar The Linux Kitten2014-03-19
| | | | | | | | | | The `-v` (verbose) flag for `cp`, `ln`, and `rm` is not standard. It is simple to implement using shell functions, so introduce `cp_v`, `ln_v`, and `rm_v`. These shell functions use the existing `$VERBOSE` variable for printing, which simplifies the code and reduces the number of variables. Fixes #61.
* Quote $@Gravatar patrick brisbin and Mike Burns2014-03-05
| | | | | | | | | Most of this commit is actually about $IFS. Modifying the environment for a single invocation (i.e. with `VAR=x command` or `env VAR=x command`) only works for actual commands, not a built-in like `set`. Consequently, we must manually store the existing $IFS value and restore it after invoking `set`.
* Add quoting, remove backticks, use $PWDGravatar patrick brisbin2014-03-05
| | | | | * http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08
* Symlink dirs that are tag- or host-specificGravatar Mike Burns2014-03-04
| | | | | The original `SYMLINK_DIRS` pull request had ignored the tag- and host-specific sections. This brings them back into being.
* Add quoting, remove backticks, use $PWDGravatar patrick brisbin2014-03-04
| | | | | | | | | * http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08 Fixes #46. This does not handle quotes around `$@`. That is taken separately in #53.
* Quotes around the arguments to diffGravatar Caleb Land2014-03-03
|
* Quote the PWDGravatar Mike Burns2014-02-27
| | | | | | | | | This allows for users to run this command from within directories that have spaces in their path. I've also quoted `DOTFILES_DIR` in more places, but this is so far a waste: we still don't support dotfiles directories with spaces in their name.
* -d is relative to the $PWDGravatar Mike Burns2014-02-27
| | | | | | | | | | | | | | | | | | | | | | | This case fails: ~% lsrc -d foo -d bar /home/mike/.zshrc:/home/mike/foo/zshrc Because: skipping non-existent directory: /home/mike/foo/bar However, giving the absolute path fixes it: ~% lsrc -d $PWD/foo -d $PWD/bar /home/mike/.zshrc:/home/mike/foo/zshrc /home/mike/.vimrc:/home/mike/bar/vimrc In this commit we fix this by storing the user's working directory when they start, and always `cd`ing back before changing dotfile directory. In this way they are always relative to the current working directory. Fixes #21.
* Handle more files with spaces and special charsGravatar Caleb Land2014-02-27
|
* Start bringing in the Makefile.am from gitshGravatar Mike Burns2014-02-26
| | | | | | | | | | | It introduces the `Makefile.am` from gitsh, and abstracts it a bit. This `Makefile.am`, or most of it, could be dropped into gitsh again. How to use it is documented in `DEVELOPERS.md`. The whole release process is more consistent and simple: `make release` to build a tarball, Homebrew, Arch, Debian, HTML (from manpages), and tag it, pushed to the various repos, and with cleanup. The `release` target is composed of smaller targets that stack well.
* Add sigil (`$`) for symlinked dir for lsrc -FGravatar Pablo Olmos de Aguilera Corradini2014-02-24
| | | | | | | The `$` sigil in `-F` indicates that the directory is symlinked instead of recurred upon. Fixes #37.
* Force some directories to be symlinksGravatar Pablo Olmos de Aguilera Corradini and Mike Burns2014-02-18
| | | | | | | | | | | | | | | | | | | | | | | Typically a directory structure is copied instead of symlinked, while files are symlinked. However, some cases require symlinked dirs: git submodules, vim plugins, and so on. This introduces a `SYMLINK_DIRS` option for rcrc(5) that takes a space-separated list of "exclude patterns". Any directory matching these patterns is symlinked. This also introduces a `-S` argument for lsrc(1), rcup(1), and rcdn(1). This argument takes a pattern, for one-off directory symlinking. It can be repeated. This also introduces `-S` and `-s` for mkrc(1). `-S` will re-install the files as symlinks, and `-s` will not. This does work with `-C`, though perhaps unintuitively - we don't know what the user means in this case. However, it will not crash. Bug: `-s` does not work right if `SYMLINK_DIRS` is set. Bug #36 addresses this.
* Prefer RCRC environment variable over ~/.rcrcGravatar patrick brisbin2013-12-11
| | | | | | | | | * Centralize configuration loading in rcm.sh(.in) * Check for readability, not just existence Add RCRC notes to all manpages. Putting the environment variables in a table lines them up more neatly and definitively, across all output formats, and also follows the examples used by e.g. BSD ls(1).
* Add generated files to .gitignoreGravatar patrick brisbin2013-12-10
|
* Run hooks by default, as the manpage indicatesGravatar patrick brisbin2013-12-10
|
* Show a difference between moving and link in mkrcGravatar Pablo Olmos de Aguilera Corradini2013-10-08
| | | | | | | | | | | | | | | | | I found that after you add a file with `mkrc` command from any dir, the output looks like: $ mkrc ~/.my-awesome-dot-file ‘$HOME/.my-awesome-dot-file -> ‘$HOME/.dotfiles/my-awesome-dot-file' ‘$HOME/.my-awesome-dot-file -> ‘$HOME/.dotfiles/my-awesome-dot-file' $ It looks like the output it's appearing twice, which could led you believe something went wrong or the output is a bit buggy. Obivously, it's not, and the command ran without problems. Use `$PRINT` to show which step it is on before the verbose messages are displayed.
* Upgrade to automake 1.14Gravatar Mike Burns2013-09-14
| | | | | This is what FreeBSD has in its ports tree and is the latest as of 21 June 2013.
* 1.1 buld cruftGravatar Mike Burns2013-09-12
| | | | Running autogen.sh changes these files. Clearly they must be important.
* Add -h for lsrc, mkrc, rcdn, rcupGravatar Mike Burns2013-08-16
| | | | Quick usage summaries for the four commands.
* Add -kK for rcup and rcdnGravatar Mike Burns2013-08-16
| | | | | The hooks can be skipped using `-K`, if needed and they can be forced with the `-k` flag.
* Pre-up, post-up, pre-down, and post-down hooksGravatar Mike Burns2013-08-16
| | | | | | | | | | | | | | | | These are programs that, if they exist, will run before or after the syncronization/removal is run. Three use cases caused this: 1. The thoughtbot dotfiles will run a vundle installation set of commands after intitial synchronization. 2. I changed the location of `.bash_history` to `.bash/history` and wanted to move `.bash_history` to `.bash/history` after up to preserve existing history. 3. Moving from an existing old-style custom install script to `rcup` might require some cleanup; this happened in practice, and required a simple script.
* Add the COPY_ALWAYS optionGravatar Mike Burns2013-08-11
| | | | | | | | | | | | | | | | | | | | The suite now honors the `COPY_ALWAYS` option in rcrc(5). This can be set to a space-separated list of file globs. Any file matching a glob is copied instead of symlinked. This is handy both for secure programs (`netrc`, `ssh/id_*`) and for programs that oddly re-write files (`weechat/*`). To always copy everything, use the `*` glob. This is reflected throughout the suite as follows: * lsrc now has a `-F` option which shows a symbol to indicate whether it is a symlink (`@`) or a copy (`X`). * rcdn only removes symlinks unless the file under question matches a `COPY_ALWAYS` glob, in which case it is removed regardless of whether it is a symlink. * rcup will copy instead of symlinking any file that matches any `COPY_ALWAYS` glob.