RS is readonly

Bug #400409 reported by Bilge
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
mawk (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: mawk

System: Ubuntu 8.04.1
mawk version: 1.3.3-11ubuntu2

Running the following in bash:
for ((i = 1; i <= 10; ++i)); do echo -ne "$i\0"; done | awk 'BEGIN {RS = "\0"}; END {print NR}'

Gives: 1
Expected: 10

mawk does not care what RS is set to.

Revision history for this message
Thomas Dickey (dickey-his) wrote :

mawk does care - but it's not accepting a explicit null-character.
I've added a fix for the next snapshot of mawk.

Revision history for this message
Bilge (bbilge) wrote :

So, uh. How long does that usually take?

Revision history for this message
Thomas Dickey (dickey-his) wrote :

If the Debian packager were responding, it would be about a week.
However, he's ignored most of my bug reports (aside from the one
about incorrect license).

Look here - I've marked fixed-upstream on the ones that I believe are
done...

http://bugs.debian.org/cgi-bin/pkgreport.cgi?package=mawk

Revision history for this message
Gert Hulselmans (hulselmansgert) wrote :
Download full text (4.1 KiB)

mawk 1.33 of Ubuntu 10.10 still has problems with RS="\0".

Part of boot info script where RS="\0" is used:
------------------------------------------------------------------------------------------
get_embedded_menu () {
  local source=$1 titlename=$2;

  # Check if magic bytes that go before the embedded menu, are present.
  offset_menu=$(dd if="${source}" count=4 bs=128k 2>> ${Trash} | hexdump -v -e '/1 "%02x"' | grep -b -o 'b0021ace000000000000000000000000');

  if [ -n ${offset_menu} ] ; then
     # Magic found.
     titlebar_gen "${titlename}" " embedded menu";
     echo '--------------------------------------------------------------------------------' >> "${Log1}";

     # Calcutate the exact offset to the embedded menu.
     offset_menu=$(( ( ${offset_menu%:*} / 2 ) + 16 ));
  dd if="${source}" count=1 skip=1 bs=${offset_menu} 2>> ${Trash} | ${AWK} 'BEGIN { RS="\0" } { if (NR == 1) print $0 }' >> "${Log1}";

     echo '--------------------------------------------------------------------------------' >> "${Log1}";
  fi
}
------------------------------------------------------------------------------------------

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

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

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

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 partition:
http://code.google.com/p/grub4dos-chenall/downloads/list

Compile the new 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

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
  sudo bash boot_info_script-mawk-1.3.4.sh RESULT-mawk-1.3.4.txt

Compare the output files:
  diff -u RESULT-mawk-1.3.3.txt RESULT-gawk.txt ==> a lot of differences
  diff -u RESULT-mawk-1.3.4.txt RESULT-gawk.txt ==> no difference

For mawk-1.3.3, you will see something like this:
========================== sdb1/grldr embedded menu: ===========================

--------------------------------------------------------------------------------
pxe detect
configfile
default 0
timeout 1
--------------------------------------------------------------------------------

For gawk and mawk-1.3.4, you will see something like this (correct):
========================== sdb1/grldr embedded menu: ===========================

--------------------------------------------------------------------------------
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/...

Read more...

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
Revision history for this message
Bilge (corporate) wrote :

"About a week". 3 years later the problem still plagues me.

Revision history for this message
Boyuan Yang (hosiet) wrote :

This issue is fixed in Ubuntu 20.04 and later releases.

As Ubuntu 18.04 and all earlier releases no longer receive standard support after 2023-06, the fix won't be available in those Ubuntu releases through standard channels. If you want to have it fixed via Ubuntu LTS, please directly consult with Ubuntu LTS persons.

As a result, marking this bug as fix released.

Changed in mawk (Ubuntu):
status: Confirmed → Fix Released
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.