Properly quote in fetch scripts

This commit is contained in:
Markus Koch 2020-04-26 17:22:44 +02:00
parent 2f02ca1d2a
commit 98cd0c8fe9
2 changed files with 7 additions and 7 deletions

View File

@ -1,14 +1,14 @@
#!/bin/bash
json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Cities'`
data=`echo $json | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
echo "["
export IFS="}"
for entry in $data; do
name=`echo $entry | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'`
type=`echo $entry | sed -n 's/\s*\([^|]\+\)||\s*\([^|]\+\).*/\2/p' | sed 's/ $//'`
coord=`echo $entry | sed -n 's/.*||\s*\([^|]\+\).*/\1/p'`
name=`echo "$entry" | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'`
type=`echo "$entry" | sed -n 's/\s*\([^|]\+\)||\s*\([^|]\+\).*/\2/p' | sed 's/ $//'`
coord=`echo "$entry" | sed -n 's/.*||\s*\([^|]\+\).*/\1/p'`
if [[ "$name" != "" && "$coord" != "" ]]; then
echo "{ \"type\": \"Feature\",
\"geometry\": {

View File

@ -3,13 +3,13 @@
# WARNING: This script is not yet production ready. The slightest error in the wikipage can throw it off. Handle with care.
json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Maps:Streets'`
data=`echo $json | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
data=`echo "$json" | json_reformat | sed -e 's/\\\\n//g' -n -e 's/begin:mapdata\([^}]\+\)/\1/gp' | sed -e "s/|-|/}/g"`
echo "["
export IFS="}"
for entry in $data; do
name=`echo $entry | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'`
coord=`echo $entry | sed -n 's/.*||\s*\([^|]\+\).*/\1/p'`
name=`echo "$entry" | sed -n 's/\s*\([^|]\+\).*/\1/p' | sed 's/ $//'`
coord=`echo "$entry" | sed -n 's/.*||\s*\([^|]\+\).*/\1/p'`
if [[ "$name" != "" && "$coord" != "" ]]; then
echo "{ \"type\": \"Feature\",
\"geometry\": {