#!/bin/bash # Download and compare text from two URLs in parallel # License: LGPLv2 # Author: # http://www.pixelbeat.org/ # Be careful to quote URLs appropriately like: # urldiff 'URL1' 'URL2' # Follow redirections and only show errors as generally # text for comparison is relatively small curl --version &>/dev/null && global URLGET := '"curl -sS -L'" || global URLGET := '"wget -nv -O-'" # Download in parallel and compare idiff $[$URLGET $1] $[$URLGET $2] # Note it would be better to avoid diffing if one of the URLGETs fail, # though that would involve manipulating named pipes directly, # so KISS and rely on error messages and only addition of lines, # to indicate (partial) errors. (CommandList children: [ (Sentence child:(C {(curl)} {(--version)}) terminator:) (AndOr children: [ (SimpleCommand redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[35])] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:URLGET) op: Equal rhs: {(DQ ("curl -sS -L"))} spids: [40] ) ] spids: [40] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:URLGET) op: Equal rhs: {(DQ ("wget -nv -O-"))} spids: [47] ) ] spids: [47] ) ] op_id: Op_DPipe ) ] op_id: Op_DAmp ) (C {(idiff)} { (CommandSubPart command_list: (CommandList children: [(C {($ VSub_Name "$URLGET")} {(DQ ($ VSub_Number "$1"))})] ) left_token: spids: [58 64] ) } { (CommandSubPart command_list: (CommandList children: [(C {($ VSub_Name "$URLGET")} {(DQ ($ VSub_Number "$2"))})] ) left_token: spids: [66 72] ) } ) ] )