make _create_or_patch_scmbrc noclobber safe

use >| instead of > to override noclobber on write (works for both bash and zsh)
This commit is contained in:
keen99
2014-07-08 16:01:58 -04:00
parent 3e09624f8a
commit a1afeef0c4

View File

@@ -48,7 +48,7 @@ _create_or_patch_scmbrc() {
# If file exists, attempt to update it with any new settings # If file exists, attempt to update it with any new settings
elif [ -n "$1" ]; then elif [ -n "$1" ]; then
# Create diff of example file, substituting example file for user's config. # Create diff of example file, substituting example file for user's config.
git diff $1 "$prefix""scmbrc.example" | sed "s/$prefix""scmbrc.example/.$prefix""scmbrc/g" > $patchfile git diff $1 "$prefix""scmbrc.example" | sed "s/$prefix""scmbrc.example/.$prefix""scmbrc/g" >| $patchfile
if [ -s $patchfile ]; then # If patchfile is not empty if [ -s $patchfile ]; then # If patchfile is not empty
cd "$HOME" cd "$HOME"
# If the patch cannot be applied cleanly, show the updates and tell user to update file manually. # If the patch cannot be applied cleanly, show the updates and tell user to update file manually.