[Dplr-commits] r797 - pkg/dplR
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 9 16:37:12 CEST 2014
Author: mvkorpel
Date: 2014-04-09 16:37:12 +0200 (Wed, 09 Apr 2014)
New Revision: 797
Added:
pkg/dplR/svnclean.sh
Modified:
pkg/dplR/.Rbuildignore
Log:
Cleanup script that removes all files not under version control (svn).
Andy: This should clean up your dplR working copy. Call it in the dplR
directory. Try the -l option first.
Modified: pkg/dplR/.Rbuildignore
===================================================================
--- pkg/dplR/.Rbuildignore 2014-04-09 11:26:33 UTC (rev 796)
+++ pkg/dplR/.Rbuildignore 2014-04-09 14:37:12 UTC (rev 797)
@@ -1,3 +1,4 @@
^dplR-Ex\.R$
+^[^/]*\.sh$
^(.*/)?svn.*\.tmp$
^(.*/)?\..+$
Added: pkg/dplR/svnclean.sh
===================================================================
--- pkg/dplR/svnclean.sh (rev 0)
+++ pkg/dplR/svnclean.sh 2014-04-09 14:37:12 UTC (rev 797)
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+
+# http://stackoverflow.com/questions/5474732/how-can-i-add-a-help-method-to-a-shell-script
+usage="$(basename "$0") [-h] [-l] [-p]
+
+Remove files that are not controlled by svn,
+
+where:
+ -h show this help text
+ -p prompt before every removal (default: force, i.e. never ask)
+ -l only list the files to be removed"
+
+listfiles=0
+rmprompt=0
+# http://stackoverflow.com/questions/4882349/parsing-shell-script-arguments
+while [[ $1 == -* ]]; do
+ case "$1" in
+ -h) echo "$usage"; exit;;
+ -l) listfiles=1; shift;;
+ -p) rmprompt=1; shift;;
+ -*) echo "invalid option: $1" 1>&2; exit 1;;
+ esac
+done
+
+# http://stackoverflow.com/questions/4515586/clean-an-svn-checkout-remove-non-svn-files
+if [ $listfiles -eq 1 ]; then
+ svn status --no-ignore | grep '^[?I]' | sed "s/^[?I] //" | xargs -I{} echo "{}"
+elif [ $rmprompt -eq 1 ]; then
+ svn status --no-ignore | grep '^[?I]' | sed "s/^[?I] //" | xargs -p -I{} rm -rf "{}"
+else
+ svn status --no-ignore | grep '^[?I]' | sed "s/^[?I] //" | xargs -I{} rm -rf "{}"
+fi
Property changes on: pkg/dplR/svnclean.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
More information about the Dplr-commits
mailing list