diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -47,6 +47,7 @@ testpats = [ (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'"), diff --git a/tests/test-record.t b/tests/test-record.t --- a/tests/test-record.t +++ b/tests/test-record.t @@ -919,7 +919,8 @@ Editing patch $ 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 @@ Removing changes from patch $ 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 < 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 <