"mawk -F '\0' '{print $1}'" doesn't give the expected result

Bug #716920 reported by Gert Hulselmans
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
mawk (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: mawk

'mawk -F '\0' '{print $1}''' doesn't give the expected result.

Mawk version of Ubuntu 10.10.

How to reproduce:
-----------------------

Download the last development version of boot_info_script:
  wget -O boot_info_script.sh 'http://bootinfoscript.git.sourceforge.net/git/gitweb.cgi?p=bootinfoscript/bootinfoscript;a=blob_plain;f=boot_info_script-gawk.sh;hb=HEAD'

Replace gawk with mawk:
  sed -e 's|gawk|mawk|' boot_info_script-gawk.sh > boot_info_script-mawk-1.3.3.sh

Copy grldr (grub4dos) file to the root of a drive:
http://code.google.com/p/grub4dos-chenall/downloads/list

Run boot_info_script-gawk.sh and boot_info_script-mawk-1.3.3.sh:
  sudo bash boot_info_script-gawk.sh RESULT-gawk.txt
  sudo bash boot_info_script-mawk-1.3.3.sh RESULT-mawk-1.3.3.txt

Compare the output files:
  diff -u RESULT-mawk-1.3.3.txt RESULT-gawk.txt

If you also have grub(2) or Syslinux installed, you will see something like this:

================================================================
@@ -269,30 +269,31 @@
 ========================== sda3/grldr embedded menu: ===========================

 --------------------------------------------------------------------------------
-p
-c
-d
-t
-
-tI also found tha
-
-
-
-
-
-
-
-
-
+pxe detect
+configfile
+default 0
+timeout 1
+
+title find /menu.lst, /boot/grub/menu.lst, /grub/menu.lst
+ errorcheck off
+ configfile /menu.lst || configfile /MENU.LST
+ configfile /boot/grub/menu.lst || configfile /BOOT/GRUB/MENU.LST
+ configfile /grub/menu.lst || configfile /GRUB/MENU.LST
+ find --set-root --ignore-floppies --ignore-cd /menu.lst && configfile /menu.lst
+ find --set-root --ignore-floppies --ignore-cd /boot/grub/menu.lst && configfile /boot/grub/menu.lst
+ find --set-root --ignore-floppies --ignore-cd /grub/menu.lst && configfile /grub/menu.lst
+ errorcheck on
+ commandline

-t
-
+title commandline
+ commandline

-t
-
+title reboot
+ reboot
+
+title halt
+ halt

-t
-

 --------------------------------------------------------------------------------

@@ -300,16 +301,16 @@

            GiB - GB File Fragment(s)

- 5.718446419 = 6.140135088 boot/grub/core.img 1
- 4.713656705 = 5.061250348 boot/grub/grub.cfg 1
- 4.369430542 = 4.691640320 boot/initrd.img-2.6.35-22-generic 2
- 4.380689126 = 4.703729133 boot/initrd.img-2.6.35-24-generic 2
- 4.402975082 = 4.727658496 boot/initrd.img-2.6.35-25-generic 2
- 5.724097232 = 6.146202603 boot/vmlinuz-2.6.35-22-generic 1
- 5.750058217 = 6.174077998 boot/vmlinuz-2.6.35-24-generic 1
- 5.752313210 = 6.176499278 boot/vmlinuz-2.6.35-25-generic 1
- 4.402975082 = 4.727658496 initrd.img 2
- 4.380689126 = 4.703729133 initrd.img.old 2
- 5.752313210 = 6.176499278 vmlinuz 1
- 5.750058217 = 6.174077998 vmlinuz.old 1
+ 18.498229980 = 19.862323200 boot/grub/core.img 1
+ 8.435592651 = 9.057648640 boot/grub/grub.cfg 1
+ 4.988281250 = 5.356126208 boot/initrd.img-2.6.35-22-generic 2
+ 5.101032257 = 5.477191680 boot/initrd.img-2.6.35-24-generic 2
+ 5.324218750 = 5.716836352 boot/initrd.img-2.6.35-25-generic 2
+ 18.554821014 = 19.923087360 boot/vmlinuz-2.6.35-22-generic 1
+ 18.814811707 = 20.202250240 boot/vmlinuz-2.6.35-24-generic 1
+ 18.837394714 = 20.226498560 boot/vmlinuz-2.6.35-25-generic 1
+ 5.324218750 = 5.716836352 initrd.img 2
+ 5.101032257 = 5.477191680 initrd.img.old 2
+ 18.837394714 = 20.226498560 vmlinuz 1
+ 18.814811707 = 20.202250240 vmlinuz.old 1
================================================================

You will see that the embedded grub4dos config file is not extracted right (mawk -F '\0').
You can also notice that mawk 1.3.3 calculates the values of "GiB - GB" wrong.

I found a version of mawk, maintained by a new developer:
  http://invisible-island.net/mawk/

New mawk changelog (debian patches included + new things):
  http://invisible-island.net/mawk/CHANGES

When I compile this version of mawk and do:
  sed -e 's|gawk|/home/user/mawk-1.3.4-20100625/mawk|' boot_info_script-gawk.sh > boot_info_script-mawk-1.3.4.sh

  sudo bash boot_info_script-mawk-1.3.4.sh
  diff -u RESULT-mawk-1.3.4.txt RESULT-gawk.txt

The output of the mawk-1.3.4 and gawk version are exactly the same.

This new version of mawk probably solves a lot of the outstanding bugs on this list too.
Can the last version of mawk-1.3.4 be included in Ubuntu 11.04 and Ubuntu 10.10?

Revision history for this message
Gert Hulselmans (hulselmansgert) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mawk (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.