summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGravatar Mike Burns <mike@mike-burns.com>2013-08-05 04:41:38 +0200
committerGravatar Mike Burns <mike@mike-burns.com>2013-08-05 05:57:18 +0200
commit122bbf0c6da226fc7e8a7e2a8d173b3e6259f7cf (patch)
treea161a071a42e9af7bd7feb301a0497e7d8a2b147 /bin
parent63b50643b0ffd287d0070e494625056a05081ce8 (diff)
Inclusionary patterns: -I
The `-I` flag serves as an "undo" for the `-e` pattern. It overrides any matching exclusions, allowing for temporary listing/installation/removal. For example, if you want to try a `.pythonrc` but leave it in your `EXCLUDES` in rcrc(5), you can do: rcup -Ipythonrc pythonrc
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lsrc48
-rwxr-xr-xbin/mkrc2
-rwxr-xr-xbin/rcdn7
-rwxr-xr-xbin/rcup7
4 files changed, 45 insertions, 19 deletions
diff --git a/bin/lsrc b/bin/lsrc
index 6267f03..9ed2a71 100755
--- a/bin/lsrc
+++ b/bin/lsrc
@@ -35,15 +35,16 @@ link_dir() {
local dotfiles_dir=$3
local dotted=$4
local exclude_file_globs="$5"
+ local include_file_globs="$6"
local dest_path=`build_path $dest_dir $dir $dotted`
- $DEBUG "link_dir $1 $2 $3 $4 $5"
+ $DEBUG "link_dir $1 $2 $3 $4 $5 $6"
$VERBOSE "recurring on $dest_path"
pushdir $dir
for f in *; do
$DEBUG "handling the file $f"
- handle_file $f $dest_path $dotfiles_dir/$dir 1 "$exclude_file_globs"
+ handle_file $f $dest_path $dotfiles_dir/$dir 1 "$exclude_file_globs" "$include_file_globs"
done
popdir
}
@@ -68,15 +69,16 @@ handle_file() {
local dotfiles_dir=$3
local dotted=$4
local exclude_file_globs="$5"
+ local include_file_globs="$6"
- $DEBUG "handle_file $1 $2 $3 $4 $5"
+ $DEBUG "handle_file $1 $2 $3 $4 $5 $6"
if [ ! -e $file ]; then
$VERBOSE "skipping non-existent file $file"
- elif is_excluded $file "$exclude_file_globs"; then
+ elif is_excluded $file "$exclude_file_globs" "$include_file_globs"; then
$VERBOSE "skipping excluded file $file"
elif [ -d $file ]; then
- link_dir $file $dest_dir $dotfiles_dir $dotted "$exclude_file_globs"
+ link_dir $file $dest_dir $dotfiles_dir $dotted "$exclude_file_globs" "$include_file_globs"
else
link_file $file $dest_dir $dotfiles_dir $dotted
fi
@@ -91,11 +93,12 @@ is_metafile() {
dotfiles_dir_excludes() {
local dotfiles_dir=$1
+ local excludes="$2"
$DEBUG "dotfiles_dir_excludes $dotfiles_dir"
- $DEBUG " with EXCLUDES: $EXCLUDES"
+ $DEBUG " with excludes: $excludes"
- for exclude in $EXCLUDES; do
+ for exclude in $excludes; do
if echo $exclude | grep -q :; then
dotfiles_dir_pat=`echo $exclude | sed 's/:.*//'`
file_glob=`echo $exclude | sed 's/.*://'`
@@ -116,15 +119,24 @@ dotfiles_dir_excludes() {
is_excluded() {
local file=$1
local exclude_file_globs="$2"
+ local include_file_globs="$3"
- $DEBUG "is_excluded $file $exclude_file_globs"
+ $DEBUG "is_excluded $file $exclude_file_globs $include_file_globs"
- for file_glob in $exclude_file_globs; do
- $DEBUG "file_glob: $file_glob"
+ for exclude_file_glob in $exclude_file_globs; do
$DEBUG "file: $file"
+ $DEBUG "exclude_file_glob: $exclude_file_glob"
case $file in
- $file_glob) return 0;;
+ $exclude_file_glob)
+ for include_file_glob in $include_file_globs; do
+ case $file in
+ $include_file_glob) return 1;;
+ esac
+ done
+
+ return 0
+ ;;
esac
done
@@ -137,10 +149,12 @@ handle_command_line() {
local version=0
local dotfiles_dirs=
local excludes=
+ local includes=
- while getopts Vqve:t:d: opt; do
+ while getopts VqvI:e:t:d: opt; do
case "$opt" in
e) excludes="$excludes $OPTARG";;
+ I) includes="$includes $OPTARG";;
t) arg_tags="$arg_tags $OPTARG";;
v) verbosity=$(($verbosity + 1));;
q) verbosity=$(($verbosity - 1));;
@@ -154,6 +168,7 @@ handle_command_line() {
TAGS=${arg_tags:-$TAGS}
DOTFILES_DIRS=${dotfiles_dirs:-$DOTFILES_DIRS}
EXCLUDES=${excludes:-$EXCLUDES}
+ INCLUDES=${includes:-$INCLUDES}
FILES=$@
$DEBUG "TAGS: $TAGS"
@@ -181,8 +196,9 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
continue
fi
- exclude_file_globs=`dotfiles_dir_excludes $DOTFILES_DIR`
+ exclude_file_globs=`dotfiles_dir_excludes $DOTFILES_DIR "$EXCLUDES"`
$DEBUG "exclude_file_globs: $exclude_file_globs"
+ include_file_globs=`dotfiles_dir_excludes $DOTFILES_DIR "$INCLUDES"`
cd $DOTFILES_DIR
DIR_STACK=":$DOTFILES_DIR"
@@ -192,7 +208,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
continue
fi
- handle_file $file $DEST_DIR $DOTFILES_DIR 0 "$exclude_file_globs"
+ handle_file $file $DEST_DIR $DOTFILES_DIR 0 "$exclude_file_globs" "$include_file_globs"
done
cd $DOTFILES_DIR
@@ -201,7 +217,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
if [ -d $host_files ]; then
pushdir `basename $host_files`
for file in ${FILES:-*}; do
- handle_file $file $DEST_DIR $host_files 0 "$exclude_file_globs"
+ handle_file $file $DEST_DIR $host_files 0 "$exclude_file_globs" "$include_file_globs"
done
popdir
fi
@@ -213,7 +229,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
pushdir `basename tag-$tag`
for file in ${FILES:-*}; do
$DEBUG "TAG: $tag, exclude_file_globs: $exclude_file_globs"
- handle_file $file $DEST_DIR $DOTFILES_DIR/tag-$tag 0 "$exclude_file_globs"
+ handle_file $file $DEST_DIR $DOTFILES_DIR/tag-$tag 0 "$exclude_file_globs" "$include_file_globs"
done
popdir
fi
diff --git a/bin/mkrc b/bin/mkrc
index 5a70482..d3effb8 100755
--- a/bin/mkrc
+++ b/bin/mkrc
@@ -23,7 +23,7 @@ if [ -e $HOME/.rcrc ]; then
fi
if [ $# -eq 0 ]; then
- echo "Usage: mkrc [-d dir] [-t tag] [-o] [-v] [-q] filename ..."
+ echo "Usage: mkrc [-vqo] [-t tag] [-d dir] files ..."
exit 1
fi
diff --git a/bin/rcdn b/bin/rcdn
index 66e064f..a7fb81d 100755
--- a/bin/rcdn
+++ b/bin/rcdn
@@ -10,10 +10,12 @@ handle_command_line() {
local dotfiles_dirs=
local files=
local excludes=
+ local includes=
- while getopts Vqve:t:d: opt; do
+ while getopts VqvI:e:t:d: opt; do
case "$opt" in
e) excludes="$excludes $OPTARG";;
+ I) includes="$includes $OPTARG";;
t) arg_tags="$arg_tags $OPTARG" ;;
v) verbosity=$(($verbosity + 1));;
q) verbosity=$(($verbosity - 1));;
@@ -38,6 +40,9 @@ handle_command_line() {
for exclude in $excludes; do
LS_ARGS="$LS_ARGS -e $exclude"
done
+ for include in $includes; do
+ LS_ARGS="$LS_ARGS -I $include"
+ done
LS_ARGS="$LS_ARGS $files"
$DEBUG "LS_ARGS: $LS_ARGS"
diff --git a/bin/rcup b/bin/rcup
index 7c1cf16..37ccb2f 100755
--- a/bin/rcup
+++ b/bin/rcup
@@ -77,14 +77,16 @@ handle_command_line() {
local dotfiles_dirs=
local files=
local excludes=
+ local includes=
REPLACE_ALL=0
- while getopts Vqvfie:t:d: opt; do
+ while getopts VqvfiI:e:t:d: opt; do
case "$opt" in
e) excludes="$excludes $OPTARG";;
f) REPLACE_ALL=1 ;;
i) REPLACE_ALL=0 ;;
+ I) includes="$includes $OPTARG";;
t) arg_tags="$arg_tags $OPTARG" ;;
v) verbosity=$(($verbosity + 1)) ;;
q) verbosity=$(($verbosity - 1)) ;;
@@ -109,6 +111,9 @@ handle_command_line() {
for exclude in $excludes; do
LS_ARGS="$LS_ARGS -e $exclude"
done
+ for include in $includes; do
+ LS_ARGS="$LS_ARGS -I $include"
+ done
LS_ARGS="$LS_ARGS $files"
$DEBUG "LS_ARGS: $LS_ARGS"