One-liners: Difference between revisions
→Compare two wikis for extensions and skins: add footnote about one-liner not working |
No edit summary |
||
| Line 30: | Line 30: | ||
==Compare two wikis for extensions and skins== | ==Compare two wikis for extensions and skins== | ||
This one-liner invokes the API of two wikis asking for info on siteinfo, general, extensions and skins; in json format. Since that data is returned without any newlines, we use | This one-liner invokes the API of two wikis asking for info on siteinfo, general, extensions and skins; in json format. Since that data is returned without any newlines, we use <code>jq</code> to pretty-print the json output. Then it's an easy <code>meld</code> or <code>diff</code> to compare them. The <code>--silent</code> option to <code>curl</code> just suppresses the connection and retrieval metadata; while the <code>-L</code> is customary to follow redirects. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
A='https://wiki.freephile.org/wiki' B='https://www.mediawiki.org/w' API='/api.php?action=query&meta=siteinfo&siprop=general%7Cextensions%7Cskins&format=json' meld <(curl --silent -L "${A}${API}" | jq '.') <(curl --silent -L "${B}${API}" | jq '.')</syntaxhighlight> | A='https://wiki.freephile.org/wiki' B='https://www.mediawiki.org/w' API='/api.php?action=query&meta=siteinfo&siprop=general%7Cextensions%7Cskins&format=json' meld <(curl --silent -L "${A}${API}" | jq '.') <(curl --silent -L "${B}${API}" | jq '.')</syntaxhighlight> | ||
The wiki farm detection has changed (@fixme) on this site making it slightly different from mediawiki.org. Still, the one-liner should work but is failing silently whereas a manually executed substitution of <code>meld <(curl --silent -L "https://wiki.freephile.org/wiki/api.php?action=query&meta=siteinfo&siprop=general%7Cextensions%7Cskins&format=json" | jq '.') <(curl --silent -L "https://www.mediawiki.org/w/api.php?action=query&meta=siteinfo&siprop=general%7Cextensions%7Cskins&format=json" | jq '.')</code> does launch meld with the proper content. | |||
==Perl edit== | ==Perl edit== | ||