From 00626fe2703dbfc40f8b488af4d845521bc49ab8 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Thu, 27 Feb 2014 11:20:31 -0500 Subject: Add quoting, remove backticks, use $PWD * 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. --- bin/mkrc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'bin/mkrc') diff --git a/bin/mkrc b/bin/mkrc index f44cadb..d99cf36 100755 --- a/bin/mkrc +++ b/bin/mkrc @@ -1,20 +1,20 @@ #!/bin/sh -: ${RCM_LIB:=`dirname $0`/../share/rcm} -. $RCM_LIB/rcm.sh +: ${RCM_LIB:=$(dirname "$0")/../share/rcm} +. "$RCM_LIB/rcm.sh" destination() { - local dotfiles_dir=$1 + local dotfiles_dir="$1" local dotless=$2 local in_host=$3 - local tag=$4 + local tag="$4" if [ "x$tag" != "x" ]; then - echo $dotfiles_dir/tag-$tag + echo "$dotfiles_dir/tag-$tag" elif [ $in_host = 1 ]; then - echo $dotfiles_dir/host-$HOSTNAME + echo "$dotfiles_dir/host-$HOSTNAME" else - echo $dotfiles_dir + echo "$dotfiles_dir" fi } @@ -46,11 +46,11 @@ while getopts ChSsVvqot:d: opt; do case "$opt" in C) always_copy=1 ;; h) show_help ;; - t) tag=$OPTARG ;; + t) tag="$OPTARG" ;; v) verbosity=$(($verbosity + 1)) ;; q) verbosity=$(($verbosity - 1)) ;; o) in_host=1 ;; - d) DOTFILES_DIR=$OPTARG ;; + d) DOTFILES_DIR="$OPTARG" ;; V) version=1 ;; S) force_symlink=1 ;; s) force_symlink=0 ;; @@ -72,17 +72,17 @@ files=$@ if [ $force_symlink -eq 1 ]; then for file in $files; do - dedotted=`de_dot $file` + dedotted="$(de_dot "$file")" INSTALL="$INSTALL -S $dedotted" done fi for file in $files; do - dotless=`de_dot $file` - dest=`destination $DOTFILES_DIR $dotless $in_host $tag` - mkdir -p $dest/`dirname $dotless` + dotless="$(de_dot "$file")" + dest="$(destination "$DOTFILES_DIR" "$dotless" $in_host "$tag")" + mkdir -p "$dest/$(dirname "$dotless")" $PRINT "Moving..." - $MV $file $dest/$dotless + $MV "$file" "$dest/$dotless" $PRINT "Linking..." - $INSTALL -d $DOTFILES_DIR -t ${tag:--} $dotless + $INSTALL -d "$DOTFILES_DIR" -t "${tag:--}" "$dotless" done -- cgit v1.2.3