[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"-M" option does not work as expected with switch statement
From: |
Hyunho Cho |
Subject: |
"-M" option does not work as expected with switch statement |
Date: |
Sun, 05 Jul 2020 18:25:35 +0900 |
GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)
Operating System: Ubuntu 20.04 LTS
Kernel: Linux 5.4.0-39-generic
Architecture: x86-64
### Without "-M" option work as expected
bash$ awk '
{
switch ($1) { case "A" : arr[1] = $1 }
print "value: " arr[1]
}
'
A <------------ this is a user input
value: A <------------ the result as expected
### If i add "-M" option then value become "0"
bash$ awk -M '
{
switch ($1) { case "A" : arr[1] = $1 }
print "value: " arr[1]
}
'
A
value: 0 <--------- value become "0"
### No such error occurred without switch statement
bash$ awk -M '
{
arr[1] = $1
print "value: " arr[1]
}
'
A
value: A
- "-M" option does not work as expected with switch statement,
Hyunho Cho <=