@@ -41,13 +41,15 @@ for file in ${files}; do
41
41
echo " processing: $file "
42
42
IFS=
43
43
content=$( tr ' \n' ' \r' < " ${file} " | sed -r ' s/,[[:blank:]]*\r[[:blank:]]*\.\.\.//g' | sed -r ' s/\\[[:blank:]]*\r[[:blank:]]*//g' | tr ' \r' ' \n' )
44
- stop_at=$( echo " ${content} " | wc -l)
44
+ content=" ${content}
45
+ "
46
+ stop_at=$( printf ' %s' " ${content} " | wc -l)
45
47
while true ; do
46
48
line_num=$(( line_num + 1 ))
47
49
if test " ${line_num} " -gt " ${stop_at} " ; then
48
50
break
49
51
fi
50
- line=$( echo " ${content} " | head -n " ${line_num} " | tail -n 1)
52
+ line=$( printf ' %s ' " ${content} " | head -n " ${line_num} " | tail -n 1)
51
53
if [ $comment -eq 0 ] && [ $json -eq 0 ] && [ " $( echo " $line " | grep -c " ^[A-Za-z]+\|^\s*\` " ) " -eq 1 ]; then
52
54
# ignore line if it starts with 'A-Za-z' or spaces followed by '`'
53
55
continue
@@ -65,7 +67,7 @@ for file in ${files}; do
65
67
# if this is not a comment and the line starts with spaces followed by '{' or by '"' followed by "{"
66
68
json=1
67
69
# ignore any map name before top level map
68
- line=$( echo " $ line" | sed ' s/.*{/{/g' )
70
+ line=$( printf ' %s ' " ${ line} " | sed ' s/.*{/{/g' )
69
71
echo > " ${work_file} "
70
72
elif [ $comment -eq 0 ] && [ $json -eq 1 ] && [ " $( echo " $line " | grep -c " ^\s*[A-Za-z]\|^\s*\` " ) " -eq 1 ]; then
71
73
# if the line is not a comment and the line starts with spaces followed by 'A-Za-z' or followed by "`" and the parser is processing a json structure
@@ -83,7 +85,8 @@ for file in ${files}; do
83
85
if [ " $( echo " $line " | grep -c " ^\s*\.\.\s" ) " -eq 1 ]; then
84
86
echo >> " ${work_file} "
85
87
else
86
- # if file is .json the following replace in line are done:
88
+ if [ " $( echo " $file " | grep -c " \.json" ) " -eq 0 ]; then
89
+ # if file is .rst the following replace in line are done:
87
90
# 1. delete everything after '#'
88
91
# 2. delete everything after //
89
92
# 3. ignore <?include?>
@@ -94,14 +97,13 @@ for file in ${files}; do
94
97
# 8. replace ', ... ' with ' '
95
98
# 9. replace ' <DATA>' with ' "placeholder": "value"'
96
99
# 10. replace ' <DATA>' with ' "placeholder"'
97
- if [ " $( echo " $file " | grep -c " \.json" ) " -eq 0 ]; then
98
- echo " $line " | cut -d " #" -f 1 | sed ' s/\/\/ .*//g' | sed ' s/<?.*?>//g' | sed ' s/\[ <\([-A-Za-z0-9 ]*\)> \]/\[ \"<\1>\" \]/g' | sed ' s/ <\(.*\)>:/ \"<\1>\":/g' | sed ' s/: <\(.*\)>/: \"<\1>\"/g' | sed ' s/ \.\.\./ \"placeholder\": \"value\"/g' | sed ' s/, \.\.\. / /g' | sed ' s/ <\(.*\)>/ \"placeholder\": \"value\"/g' | sed ' s/ <\(.*\)>/ \"placeholder\"/g' >> " ${work_file} "
100
+ printf ' %s' " ${line} " | cut -d " #" -f 1 | sed ' s/\/\/ .*//g' | sed ' s/<?.*?>//g' | sed ' s/\[ <\([-A-Za-z0-9 ]*\)> \]/\[ \"<\1>\" \]/g' | sed ' s/ <\(.*\)>:/ \"<\1>\":/g' | sed ' s/: <\(.*\)>/: \"<\1>\"/g' | sed ' s/ \.\.\./ \"placeholder\": \"value\"/g' | sed ' s/, \.\.\. / /g' | sed ' s/ <\(.*\)>/ \"placeholder\": \"value\"/g' | sed ' s/ <\(.*\)>/ \"placeholder\"/g' >> " ${work_file} "
99
101
else
100
- # if file is .rst the following replace in line are done:
102
+ # if file is .json the following replace in line are done:
101
103
# 1. delete everything after '#'
102
104
# 2. delete everything after //
103
105
# 3. ignore <?include?>
104
- echo " $ line" | cut -d " #" -f 1 | sed ' s/\/\/ .*//g' | sed ' s/<?.*?>//g' >> " ${work_file} "
106
+ printf ' %s ' " ${ line} " | cut -d " #" -f 1 | sed ' s/\/\/ .*//g' | sed ' s/<?.*?>//g' >> " ${work_file} "
105
107
fi
106
108
fi
107
109
fi
0 commit comments