Re: awk or sed

2011-04-05 Thread Andres Perera
On Tue, Apr 5, 2011 at 10:39 PM, ali hagigat  wrote:
> I have a variable like this:
> var1=Makefile .xcompile /root/build/.config src/arch/i386/Makefile.inc
> means some words separated by spaces. I want to print each word on a
> separate line. I think I have to use "awk" or "sed" string processing
> tools. I wonder if anybody have experience with them or any other
> means to do it.
>

echo "$var" | m4 | perl -pe 's,\s+,\n,g'

>
>



Re: awk or sed

2011-04-05 Thread ali hagigat
Very nice . It worked. I want to study your book.
Thank you.
Regards

On Wed, Apr 6, 2011 at 7:47 AM, Chris F.A. Johnson  wrote:
> On Wed, 6 Apr 2011, ali hagigat wrote:
>
>> I have a variable like this:
>> var1=Makefile .xcompile /root/build/.config src/arch/i386/Makefile.inc
>> means some words separated by spaces. I want to print each word on a
>> separate line. I think I have to use "awk" or "sed" string processing
>> tools. I wonder if anybody have experience with them or any other
>> means to do it.
>
> printf "%s\n" $var1
>
>  (You might want to precede that with 'set -f'.)
>
> --
>   Chris F.A. Johnson, 
>   Author:
>   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
>   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
>



Re: awk or sed

2011-04-05 Thread Chris F.A. Johnson

On Wed, 6 Apr 2011, ali hagigat wrote:


I have a variable like this:
var1=Makefile .xcompile /root/build/.config src/arch/i386/Makefile.inc
means some words separated by spaces. I want to print each word on a
separate line. I think I have to use "awk" or "sed" string processing
tools. I wonder if anybody have experience with them or any other
means to do it.


printf "%s\n" $var1

  (You might want to precede that with 'set -f'.)

--
   Chris F.A. Johnson, 
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)



awk or sed

2011-04-05 Thread ali hagigat
I have a variable like this:
var1=Makefile .xcompile /root/build/.config src/arch/i386/Makefile.inc
means some words separated by spaces. I want to print each word on a
separate line. I think I have to use "awk" or "sed" string processing
tools. I wonder if anybody have experience with them or any other
means to do it.



Unexpected behavior with TZ

2011-04-05 Thread gmail

Hello,

While looking after the multibyte test, i notice a behavior with 
printf3.sub that surprises me.


The following screen caps are a good resume :


[user@pompomgalli] $ cd bash-4.2_build

[user@pompomgalli] $ ./bash

[user@pompomgalli] $ echo $TZ

Europe/Paris

[user@pompomgalli] $ echo $LC_ALL

C

[user@pompomgalli] $ echo $LANG

fr_FR

[user@pompomgalli] $ date

Tue Apr  5 22:04:38 CEST 2011

[user@pompomgalli] $ TZ=EST5EDT

[user@pompomgalli] $ export TZ

[user@pompomgalli] $ LC_ALL=C

[user@pompomgalli] $ export LC_ALL

[user@pompomgalli] $ LANG=C

[user@pompomgalli] $ export LANG

[user@pompomgalli] $ printf "%-40.50(%a %b %e %H:%M:%S %Z %Y)T 
date-style time\n" 1275250155


Sun May 30 22:09:15 CEST 2010date-style time

[user@pompomgalli] $ date

Tue Apr  5 16:05:32 EDT 2011

[user@pompomgalli] $ printf "%-40.50(%a %b %e %H:%M:%S %Z %Y)T 
date-style time\n" 1275250155


Sun May 30 16:09:15 EDT 2010 date-style time



I see in the CHANGES that bash is able to detect TZ change and call 
tzset() if available,

i then check the build's config.log :


[root@pompomgalli] # grep -i tz config.log

configure:13502: checking for tzset
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
| #define HAVE_TZSET 1
ac_cv_func_tzset=yes
#define HAVE_TZSET 1



I have probably misunderstood something, or perhaps something is wrong 
with my build environment or there could be a side effect when  building 
in a chrooted jail.
Or perhaps it is an expected behavior with Linux/Glibc arch ? (in all 
this cases, sorry for the disturbance)






Another point, i see that the tests/intl2.sub make a direct call to a
"/usr/bin/printf" command.

The intent was to see if and how bash differs from the system printf
binary (not necessarily coreutils) when changing the locale for the
duration of the command.  Bash versions before bash-4.2 had a problem
with assignments to LANG preceding builtins.  The old versions didn't
temporarily change the locale, though they performed the variable
assignment.

Chet


Not necessarily coreutils, right ^^.



Regards, Cédric.



Re: Potential bug in library search for libiconv in static build

2011-04-05 Thread Chet Ramey
On 4/5/11 3:22 PM, gmail wrote:
> 
> Hello,
> 
> I have to apologize because i have not fully read you, there probably a
> more efficient way to deal with static librariries in the iconv distribution.
> Therefore, the suggested patch was of no use.

It has the advantage of working.  I haven't identified a better way to
do it yet.

> Another point, i see that the tests/intl2.sub make a direct call to a
> "/usr/bin/printf" command.

The intent was to see if and how bash differs from the system printf
binary (not necessarily coreutils) when changing the locale for the
duration of the command.  Bash versions before bash-4.2 had a problem
with assignments to LANG preceding builtins.  The old versions didn't
temporarily change the locale, though they performed the variable
assignment.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: Potential bug in library search for libiconv in static build

2011-04-05 Thread gmail


Hello,

I have to apologize because i have not fully read you, there probably a 
more efficient way to deal with static librariries in the iconv 
distribution.

Therefore, the suggested patch was of no use.

Another point, i see that the tests/intl2.sub make a direct call to a 
"/usr/bin/printf" command.


Considering the bash package provide a builtin printf and no printf 
binary, i wonder if this is a test to check the underlying coreutils...
Perhaps because the printf coreutils/shutils command was used in the 
build process and the tests suite should verify it was effectively usable  ?


Regards, Cedric.




Hello,


I have take a deep breath and dive in the autotools documentation.

Here is the resulting patch that i think (hope ?) should be ok with 
any hosts/shells/archs :



--- bash-4.2_static/aclocal.m4.orig 2011-04-03 14:02:35.0 
+0200

+++ bash-4.2_static/aclocal.m4  2011-04-05 00:24:55.0 +0200
@@ -3098,7 +3098,9 @@
   found_so=
   found_a=
   if test $use_additional = yes; then
-if test -n "$shlibext" && test -f 
"$additional_libdir/lib$name.$shlibext"; then
+   dnl A shared AND a static version of the same library 
could be present,
+   dnl therefore if build is static only the static version 
must be looked for.
+if test -n "$shlibext" && test -f 
"$additional_libdir/lib$name.$shlibext" && test "$opt_static_link" = 
no; then

   found_dir="$additional_libdir"
   found_so="$additional_libdir/lib$name.$shlibext"
   if test -f "$additional_libdir/lib$name.la"; then
@@ -3120,7 +3122,9 @@
   case "$x" in
 -L*)
   dir=`echo "X$x" | sed -e 's/^X-L//'`
-  if test -n "$shlibext" && test -f 
"$dir/lib$name.$shlibext"; then
+ dnl A shared AND a static version of the same 
library could be present,
+ dnl therefore if build is static only the static 
version must be looked for.
+  if test -n "$shlibext" && test -f 
"$dir/lib$name.$shlibext" && test "$opt_static_link" = no; then

 found_dir="$dir"
 found_so="$dir/lib$name.$shlibext"
 if test -f "$dir/lib$name.la"; then



04/04/2011 16:04, Chet Ramey :

On 4/3/11 9:01 AM, gmail wrote:

Hello,

This is my first contact and mail with bash mailing list, to 
summarize i'm
a coder maintening a personnal home server using several GNU tools 
since

the late 90's.


I configure BASH-4.2.0 in a chroot jail (gcc 4.5.2/libc 2.13/binutils
2.21/make 3.82) with an athlon architecture on ext3 FS with
--enable-static-link --with-libiconv-prefix=/ and, as root,  and 
notice the

configure script can't find the jail's static libiconv :
[...]
So, as you could see, the configure script try to build a static elf by
linking object output with a shared libiconv.so library.
Guessing that this behavior was not the script real goal, i then 
adapt the

configure script this way :

It's usually better to modify configure.in/aclocal.m4 and then rebuild
configure, but I see what you're trying to do.  I picked up these macros
from the libiconv distribution, so I'll have to take a look at what that
distribution needs to inhibit searching for static libraries.  It's
probably something as simple as setting a different shell variable in
configure.


For information, the configure script needs other adaptations to 
produce a
functionnal STATIC bash elf with glibc 2.13 due to specific dlopen 
issue.
I have currently inhibit getaddrinfo, gethostbyname, getpwent,  
getpwam,

getpwuid, getservbyname, getservent use in configure script when STATIC
build is required and alter some sources to behave differently if in 
static

build.
This way i have actually a functionnal static bash 4.2 elf which 
passes all
the tests except the multybite printf2.sub test (return 195 and not 
192,

i'm currently investigating).
I can provide the related patchs, if you think it's worth it.
Sure, I'd be interested in taking a look at your patches.  Note that 
this

is mostly a linux-specific issue.

Chet







Re: bashref - FUNCNEST

2011-04-05 Thread Roman Rakus

On 04/05/2011 03:43 PM, Roman Rakus wrote:
The FUNCNEST variable is described unnecessarily twice. In section 3.4 
Shell Functions, pages 16 and 17.


RR
As always I've done mistakes. It is section 3.3. The version of bash is 
4.2 (the latest released).


RR



bashref - FUNCNEST

2011-04-05 Thread Roman Rakus
The FUNCNEST variable is described unnecessarily twice. In section 3.4 
Shell Functions, pages 16 and 17.


RR