bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem:bash_builtin:mapfile:option_C:executing_indxed_array_value:bette


From: Bruxo Pi
Subject: Problem:bash_builtin:mapfile:option_C:executing_indxed_array_value:better_english_and_more_info
Date: Sun, 31 Jul 2011 07:24:36 -0700 (PDT)

Configuration Information [Automatically generated, do not change]:

Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 -Wall
uname output: Linux mach 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 
UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 8
Release Status: release

Description:

Bash bultin 'mapfile', with -C option, executes any value read from stdin. The 
usage - from bash_ref.pdf - is:
mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c 
quantum] [array]
My command:

$ mapfile -t -n 4 -c 2 -C let _par++ _vet

Well, when it reads the second and fourth entries, from stdin, and IF the entry 
is equal to or contains 'ç' or 'Ç', it complains, eath 2 line (normal), with 
the erro message (not normal):
./test.sh: linha 8: let: Ç: erro de sintaxe: operando esperado (token com erro 
é "Ç")
[translated: $0: line 8: let: Ç: syntax error: expected operand (error token 
with "Ç")]

It seems like bash executes 'let' builtin with the value of my array. So, I 
tried to isolate the command 'let _par++':

$ mapfile -t -n 4 -c 2 -C 'let _par++' _vet

An error ocurred also with the value 09 (it interprates as octal, because 09 
does not exist in octal).
Then, I tried to put the name of my array before the -C option:

$ mapfile -t -n 4 -c 2 _vet -C 'let _par++'

This way doesn't complain but "-C 'let _par++" is ignored too... xD

So, looks like bash does not understand when my command, to the -C option, ends 
and executes passing my array's value to the let builtin. It shouldn't be this 
way, I think and according to the bash reference.
Even if I put the '-c' option after "-C 'let _par++'" and the array's name in 
the end, doesn't work.
The sequence of events:
mapfile -t -n 4 -c 2 -C let _par++ _vet
<first value>
<second value><if 'ç' or '09', error>
./test.sh: linha 8: let: ç: erro de sintaxe: operando esperado (token com erro 
é "ç")
<third value><nothing happens>
<fourth value><an error occurs only if the value is 'Ç' or '09'>
./test.sh: linha 8: let: ç: erro de sintaxe: operando esperado (token com erro 
é "ç")
<fifth value><blank line = <enter>>

The source of test.sh:
#! /bin/bash
declare -a _vet
declare -i _par=0
function examp(){
mapfile -t -n 4 -C (let _par++) -c 2 _vet
return
}
function array_read(){
local noi
for(( noi=0 ; noi < ${#_vet[*]} ; noi++ ))
do
printf "${_vet[$noi]}."
done
printf "\n\n"
return
}
examp ; array_read

Something simple to test bash' builtin mapfile - with is really cool, ignoring 
this problem.

I use the bash debug option (-x) and I find out that it passes the value of my 
array always. And that's a problem, right?
Can you, please, tell me if it's not a problem/bug, if it's my fault, so I can 
move on with my learning? Doesn't need to say which is my error, just say that 
I'm wrong, that's enough... :)

Thank you and sorry about my english.

.pi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]