[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Strange no-print error (user script regression)
From: |
doark |
Subject: |
[bug-gawk] Strange no-print error (user script regression) |
Date: |
Tue, 17 Apr 2018 04:52:52 -0000 |
Hello,
Until recently I was using a Gentoo linux system and I used awk as my
primary scripting language (happiness). The old x86_64 machines' MB went
bad on me and I now find myself switching to an even older i586 P4 and
using Devuan ASCII Linux. I am now using gawk GNU Awk 4.1.4, API: 1.1
(GNU MPFR 3.1.5, GNU MP 6.1.2). I do not remember the previous version
but I know it followed your releases by about 2 months or less. The shell
is bash on both systems.
I had an awk script for spitting out the urls of package files I needed
to download and, with a path change, it should have worked quite well.
#############################
#!/usr/bin/gawk -f
BEGIN{
print "<DOCTYPE html>\n<head></head><body><pre>";
}
{
if($0 !~ /^$/)
{
for(i = 1; i <= NF; i++)
{
ret = split($i, a, /\//);
c = system("test -s \"/var/cache/apt/archives/" a[ret] "\"
&> /dev/null");
if(c)
{
printf("<a href=\"%s\">%s</a> ", $i, a[ret]);
}
else
{
break;
}
}
if(c)
{
print "</br></hr>";
}
}
}
END{
print "</pre></body>";
}
#############################
However, all I can get for output is this:
#############################
<DOCTYPE html>
<head></head><body><pre>
</pre></body>
#############################
Until I remove this part on line 13: "&> /dev/null". Then my script works
fine. That part of the program is a sub-shell section, unrelated to
the awk print functions. What is going on?
% echo $TERM
xterm-256color
% echo $SHELL
/bin/bash
% bash --version
GNU bash, version 4.4.12(1)-release (i686-pc-linux-gnu)
Thanks,
David
- [bug-gawk] Strange no-print error (user script regression),
doark <=