~mil/mepo-devel

1

Question regarding mepo_ui_menu_route_overpassrelation.sh

Details
Message ID
<CNM36YCH6RLJ.LMUDH3SS6ECE@PhilippN-Vostro-5490>
DKIM signature
missing
Download raw message
Hey,

I hope I'm not annoying you, but I have a question regarding the
implementation of the overpass script. Particulary, I'm interested in
the reasoning behind this code block:

> JSON_RESULTS="$(
>   curl  "${MEPO_ENDPOINT_OVERPASS}" --data-raw "data=$(
>     echo '
>       [out:json][timeout:25];
>       rel(RELATIONID);
>       (._;>>;);
>       out+body;
>       >;
>       out+skel+qt;
>     ' | sed "s/RELATIONID/$RELATIONID/g"
>   )"
> )"

The entire part after --data-raw seems overly complicated for me. Why
don't you simply put the query within double quotes and directly use the
variable $RELATIONID? Doing a command substitution, an echo and a sed
with the value of the variable seems like overkill, but it also looks
like you had something in mind when you did that. Why did you use that
approach?

Regards,
laalsaas
Details
Message ID
<3376ba25-5ce9-4025-8fb6-71e95419624c@app.fastmail.com>
In-Reply-To
<CNM36YCH6RLJ.LMUDH3SS6ECE@PhilippN-Vostro-5490> (view parent)
DKIM signature
missing
Download raw message
On Fri, Oct 14, 2022, at 8:56 PM, laalsaas wrote:
> Hey,
>
> I hope I'm not annoying you, but I have a question regarding the
> implementation of the overpass script. Particulary, I'm interested in
> the reasoning behind this code block:
>
>> JSON_RESULTS="$(
>>   curl  "${MEPO_ENDPOINT_OVERPASS}" --data-raw "data=$(
>>     echo '
>>       [out:json][timeout:25];
>>       rel(RELATIONID);
>>       (._;>>;);
>>       out+body;
>>       >;
>>       out+skel+qt;
>>     ' | sed "s/RELATIONID/$RELATIONID/g"
>>   )"
>> )"
>
> The entire part after --data-raw seems overly complicated for me. Why
> don't you simply put the query within double quotes and directly use the
> variable $RELATIONID? Doing a command substitution, an echo and a sed
> with the value of the variable seems like overkill, but it also looks
> like you had something in mind when you did that. Why did you use that
> approach?
>
> Regards,
> laalsaas

Thanks for the suggestion (!) This was indeed an ugly scripting wart I
couldn't figure out at the time and was implemented as a workaround. Per
your suggestion I have updated the two scripts using overpass that used
this workaround to remove the unnecessary sed substitutions.

https://git.sr.ht/~mil/mepo/commit/ba2a3f5

Miles
Reply to thread Export thread (mbox)