summaryrefslogtreecommitdiff
path: root/man
diff options
context:
space:
mode:
authorGravatar Edd Salkield <edd@salkield.uk>2020-01-18 18:40:45 +0000
committerGravatar Mike Burns <mburns@thoughtbot.com>2020-04-03 16:21:07 -0400
commitcbc346b279b5c08b281c9901b994a58eb037a60d (patch)
tree387a6fd63a9332e43ca9f29a4b65ada39f85f45d /man
parentf2fb351c391dca7c188a8623e71519619c2ce9a0 (diff)
Fix shell globbing bugs
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.
Diffstat (limited to 'man')
-rw-r--r--man/lsrc.17
1 files changed, 0 insertions, 7 deletions
diff --git a/man/lsrc.1 b/man/lsrc.1
index 5abf7ee..b938fee 100644
--- a/man/lsrc.1
+++ b/man/lsrc.1
@@ -190,10 +190,3 @@ We use the
program to determine the unique identifier for the host. This program is
not specified by POSIX and can vary by system. On macOS the hostname is
unpredictable, and can even change as part of the DHCP handshake.
-.Pp
-There are a few bugs around shell globs. Anything involving an exclude
-pattern is unpredictable, so use
-.Fl v
-when dealing with patterns. Specifically, globs may expand at any
-time and remain expanded for the duration of the run, which means they
-cannot be applied more than once.