Merge branch 'master' of ssh://repo.or.cz/srv/git/tgl
[tgl.git] / fix.sh
blob7a86f7ed1dbbbcbff17f3672b31f0f1bcf36b48f
1 #!/bin/bash
3 [[ $# < 1 ]] && echo "Usage: $0 files" && exit 1
5 FILES="$@"
7 function space_r_space()
9 PATTERN=$1
11 while grep -q "[\*_a-zA-Z0-9]${PATTERN}[\*_a-zA-Z0-9]" $FILES; do
12 sed "s/\([\*_a-zA-Z0-9]\)${PATTERN}\([\*_a-zA-Z0-9]\)/\1 ${PATTERN} \2/g" -i $FILES
13 done
16 function r_space()
18 PATTERN=$1
20 while grep -q "[\*_a-zA-Z0-9]${PATTERN}[\*_a-zA-Z0-9]" $FILES; do
21 sed "s/\([\*_a-zA-Z0-9]\)${PATTERN}\([\*_a-zA-Z0-9]\)/\1${PATTERN} \2/g" -i $FILES
22 done
26 space_r_space '\*='
27 space_r_space '='
28 space_r_space '=='
29 space_r_space '<'
30 space_r_space '>'
31 space_r_space '<='
32 space_r_space '>='
34 r_space ','
35 r_space ';'