Index: tools/srepl
===================================================================
--- tools/srepl	(revision 2f72560a9c8a5202ee9440a68c0e91265a9f3c69)
+++ tools/srepl	(revision 13db20447e9ad45e946906ed3a8fb2e7b7de7f23)
@@ -14,13 +14,6 @@
 }
 
-
-if [ "$1" = "--" ]; then
-	usage
-elif [ "$#" -eq 1 ]  || [ "$2" = "--" ]; then
-	pattern="$1"
-	shift
-	git grep -I -n "$pattern" "$@"
-elif [ "$#" -eq 2 ] || [ "$3" = "--" ]; then
-
+check_unstaged()
+{
 	if ( git status --porcelain | grep '^.[^ ]' ); then
 		echo "You have unstaged changes in your tree."
@@ -29,7 +22,31 @@
 		exit 1
 	fi
+}
 
-	pattern="$1"
-	replacement="$2"
+_slashify()
+{
+	# Some shells have shoddy handling of backslashes in echo.
+	printf '%s\n' "$1" | sed 's/\([^\\]\)\//\1\\\//g'
+}
+
+if [ "$1" = "--" ]; then
+	usage
+elif [ "$1" = "-d" ]; then
+	check_unstaged
+
+	pattern=`_slashify "$2"`
+	shift
+	shift
+	git grep -I -l "$pattern" "$@" | xargs sed -i "/$pattern/d"
+
+elif [ "$#" -eq 1 ]  || [ "$2" = "--" ]; then
+	pattern=`_slashify "$1"`
+	shift
+	git grep -I -n "$pattern" "$@"
+elif [ "$#" -eq 2 ] || [ "$3" = "--" ]; then
+	check_unstaged
+
+	pattern=`_slashify "$1"`
+	replacement=`_slashify "$2"`
 	shift
 	shift
