X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=blobdiff_plain;f=get-var;fp=get-var;h=9b8f93054f0a7ef0205fd2b42e30e4c0abead578;hb=ece46611b24954ba4ec16cc12e5083acc319bc41;hp=0000000000000000000000000000000000000000;hpb=3f5411d8579463cfb3e89c2aef032aa1bb0dbe3a;p=bin.git diff --git a/get-var b/get-var new file mode 100755 index 0000000..9b8f930 --- /dev/null +++ b/get-var @@ -0,0 +1,20 @@ +#! /usr/bin/perl -wn +BEGIN { + unless (defined ($var = shift)) { + print STDERR "Usage: $0 var-name\n"; + exit 1; + } +} +if (/^\Q$var\E=/) { + s/^\Q$var\E=//; + print, last unless /^'/; + do { + $quotes = (grep /'/g, (split //, $_)) % 3; + $inside = $quotes ... $quotes; + s/^'// if $inside == 1; + s/'$// if $quotes == 2 || $inside =~ /E0$/; + s/'\\''/'/g; + print; + last if $quotes == 2 || $inside =~ /E0$/; + } while (<>); +}