[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gawk NF=-2 not always caught
From: |
Dan Jacobson |
Subject: |
gawk NF=-2 not always caught |
Date: |
02 Jul 2001 11:13:28 +0800 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
Making NF negative isn't always caught and the error messages could be
clearer.
$ echo|gawk '{NF=-2}'
$ echo|gawk '{NF=-2;print}'
$ echo|gawk '{NF-=2;print}'
$ echo o|gawk '{NF-=2;print}'
gawk: field.c:145: rebuild_record: Assertion `NF != -1' failed.
Aborted
==========
awk: cmd. line:7: (FILENAME=- FNR=1) fatal error: internal error
p: line 15: 8976 Aborted awk '
function shift(p) { #optional p: how many to shift by, like the shell
if (p=="")p=1;else if (p<0) exit 33 #should print error message
for(i=1;i<=NF;i++){
$i=$(i+p)}
NF-=p #bye bye field separator too
}
{ #testing:
for (m=1;m<=10;m++){
print
shift(4)
}}
' <<!
a a
!
--
http://www.geocities.com/jidanni Tel+886-4-25854780 e-mail:restore .com.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gawk NF=-2 not always caught,
Dan Jacobson <=