One-liners: Difference between revisions
No edit summary |
→Compare two wikis for extensions and skins: add footnote about one-liner not working |
||
| 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 `jq` to pretty-print the json output. Then it's an easy `meld` or `diff` to compare them. The `--silent` option to `curl` just suppresses the connection and retrieval metadata; while the `-L` is customary to follow redirects. | 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 `jq` to pretty-print the json output. Then it's an easy `meld` or `diff` to compare them. The `--silent` option to `curl` just suppresses the connection and retrieval metadata; while the `-L` is customary to follow redirects <cite>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.</cite>. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
A='https://freephile.org/' B='https://www.mediawiki.org/' API=' | 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> | ||
==Perl edit== | ==Perl edit== | ||