changeset 16332:42e95631887d

tests: remove sed -i from test-record
author Matt Mackall <mpm@selenic.com>
date Sun, 01 Apr 2012 13:59:11 -0500
parents a5a3af000e0d
children cef9b0ac4601
files contrib/check-code.py tests/test-record.t
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Sat Mar 31 15:39:44 2012 -0500
+++ b/contrib/check-code.py	Sun Apr 01 13:59:11 2012 -0500
@@ -47,6 +47,7 @@
     (r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"),
     (r'^function', "don't use 'function', use old style"),
     (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
+    (r'sed.*-i', "don't use 'sed -i', use a temporary file"),
     (r'echo.*\\n', "don't use 'echo \\n', use printf"),
     (r'echo -n', "don't use 'echo -n', use printf"),
     (r'^diff.*-\w*N', "don't use 'diff -N'"),
--- a/tests/test-record.t	Sat Mar 31 15:39:44 2012 -0500
+++ b/tests/test-record.t	Sun Apr 01 13:59:11 2012 -0500
@@ -919,7 +919,8 @@
 
   $ cat > editor << '__EOF__'
   > #!/bin/sh
-  > sed -i.bak -e 7d -e '5s/^-/ /' "$1"
+  > sed -e 7d -e '5s/^-/ /' "$1" > tmp
+  > mv tmp "$1"
   > __EOF__
   $ chmod +x editor
   $ cat > editedfile << '__EOF__'
@@ -980,7 +981,8 @@
   $ echo "This line has been added" >> editedfile
   $ cat > editor << '__EOF__'
   > #!/bin/sh
-  > sed -i -e 's/^[-+]/ /' "$1"
+  > sed -e 's/^[-+]/ /' "$1" > tmp
+  > mv tmp "$1"
   > __EOF__
   $ chmod +x editor
   $ HGEDITOR="'`pwd`'"/editor hg record <<EOF
@@ -1011,11 +1013,13 @@
 
 Invalid patch
 
-  $ sed -i -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile
+  $ sed -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile > tmp
+  $ mv tmp editedfile
   $ echo "This line has been added" >> editedfile
   $ cat > editor << '__EOF__'
   > #!/bin/sh
-  > sed -i s/This/That/ "$1"
+  > sed s/This/That/ "$1" > tmp
+  > mv tmp "$1"
   > __EOF__
   $ chmod +x editor
   $ HGEDITOR="'`pwd`'"/editor hg record <<EOF