diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-07-02 17:36:37 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-07-02 22:57:07 +1200 |
commit | 95276f25769a0607cda50041169197d0522b98ff (patch) | |
tree | 3a4738901390c94f76de6ee7b6394d39b4c1ed00 /bin/xrq.awk | |
parent | Coerce seed to number (diff) | |
download | dotfiles-95276f25769a0607cda50041169197d0522b98ff.tar.gz dotfiles-95276f25769a0607cda50041169197d0522b98ff.zip |
Lots of cleanup of awk scripts
Mostly inspired by suggestions from gawk --lint
Diffstat (limited to 'bin/xrq.awk')
-rw-r--r-- | bin/xrq.awk | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/xrq.awk b/bin/xrq.awk index 686cf677..62253bdb 100644 --- a/bin/xrq.awk +++ b/bin/xrq.awk @@ -8,12 +8,16 @@ BEGIN { # Check we have at least one resource name if (ARGC < 2) { - print "xrq: Need at least one resource name" | "cat >&2" + stderr = "cat >&2" + print "xrq: Need at least one resource name" | stderr + close(stderr) exit(2) } # Run `xrdb -query` and search for instances of the requested resource - while ("xrdb -query" | getline) { + xrdb = "xrdb -query" + found = 0 + while (xrdb | getline) { for (i in ARGV) { if ($1 == ARGV[i]) { found = 1 @@ -21,6 +25,7 @@ BEGIN { } } } + close(xrdb) # Exit successfully if we found at least one result exit(!found) |