[Fwd: Re: printf -v variable ignores nullglob]

2007-05-24 Thread Elmar Stellnberger
 printf -v var %b @(hugo); echo x${var}x
x/src/m3/libs/m3core/LINUXLIBC6/*.@(m3|i3|ig|mg)x
 set | grep /src/ezm3/libs/m3core/LINUXLIBC6/*.@(m3|i3|ig|mg)
 alias | grep /src/ezm3/libs/m3core/LINUXLIBC6/*.@(m3|i3|ig|mg)
 pwd
/
 dirs
/


To me it does strongly look like a memory corruption.
* There is absolutely no hint where the string
/src/m3/libs/m3core/LINUXLIBC6/ could permissibly come from.
*  /src/m3/libs/m3core/LINUXLIBC6/ has been a previous working
directory but should be present nowhere in memory by now.
* The error occurs in a rather nondeterministic manner.
* It does not occur on startup but right after some time of working.

P.S.: Please do not wipe this under your table. It has occured more than
once.


---BeginMessage---

   Chet Ramey wrote:

Elmar Stellnberger wrote:
  

Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux
Compiler: gcc -I/usr/src/packages/BUILD/bash-3.1
-L/usr/src/packages/BUILD/bash-3.1/../readline-5.1
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586'
-DCONF_OSTYPE='linux' -DCONF_MACHTYPE='i586-suse-linux'
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -O2 -march=i586
-mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g
-D_GNU_SOURCE -DRECYCLES_PIDS -Wall -pipe -g -fbranch-probabilities
uname output: Linux sonic 2.6.16.21-0.25-default #1 Tue Sep 19 07:26:15
UTC 2006 i686 i686 i386 GNU/Linux
Machine Type: i586-suse-linux

Bash Version: 3.1
Patch Level: 17
Release Status: release

Repeat By:
1. shopt -s nullglob extglob
2. echo x$(printf %b @(hugo))x
3. printf -v var %b @(hugo); echo x${var}x
# note: no file named hugo is allowed to reside in the current working
directory

Expected Behaviour:
2. xx
3. xx

Actual Behaviour:
2. xx
3. x/current/working/directory/*.@(m3|i3|ig|mg)x


I can't reproduce this with bash-3.1 or bash-3.2.
ez
Chet

  

   ** initial Konsole #0 **
shopt -s nullglob extglob
printf -v var %b @(hugo); echo x${var}x
   x/src/m3/libs/m3core/LINUXLIBC6/*.@(m3|i3|ig|mg)x
shopt nullglob extglob
   nullglobon
   extglob on
   This is in a fact strange since the error does not seem to occur in a newly
   opened bash session:
   ** Konsole #1 **
printf -v var %b @(hugo); echo x${var}x
   xx
   Nevertheless I have not shut my computer down since I have reported this bug
   and the konsole where the nullglob error occurs is still open (Konsole #0)!
   ** Konsole #2 **
printf -v var %b @(hugo); echo x${var}x
   x@(hugo)x
echo x${var}x
   x@(hugo)x
   Very strange!! I have not found out yet when it does occur and when not.
   The error has now arised in a another konsole session:
   ** initial Konsole #0 (still open; konsole of initial bug report) **
printf -v var %b @(hugo); echo x${var}x
   x/src/m3/libs/m3core/LINUXLIBC6/*.@(m3|i3|ig|mg)x
echo $var
..
   Note: In this example the value of var is corrupted only if it is used
   within the same line of code!!
   In #2 var keeps the wrong value.
---End Message---
___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


ssh timeout

2007-05-24 Thread Lango

Hi,
I created a number of scripts that step through a file containing server
names.  It will then run a command through an ssh session on the remote
servers.
The list of servers is quite long and often an ssh session cannot be
established for one reason or another.
I am trying to find a way to define a timeout value after which the script
will no longer attempt to talk to the server and go on to the next server in
the list.
How can I accomplish that?
Here is part of my script:
 - - - - - - 8 - - - - - 
until [ $done ]
do
read 3 servername 
if [ $? != 0 ]; then
done=1
continue
fi
  ...
cat  bkuplist.$$ |ssh $servername sudo tar -zcf
/tmp/$servername.tar.gz `cat -`  2 /dev/null
scp $servername:/tmp/$servername.tar.gz $ESSPATH/ 2 /dev/null
  ...
done
 - - - - - - 8 - - - - - 
Any help is appreciated and thanks in advance.

Lango
-- 
View this message in context: 
http://www.nabble.com/ssh-timeout-tf3807052.html#a10774519
Sent from the Gnu - Bash mailing list archive at Nabble.com.



___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: last element of an array

2007-05-24 Thread Andreas Schwab
Poor Yorick [EMAIL PROTECTED] writes:

 The syntax I'm currently using to access the last element of an array looks a 
 little evil:

arr=( one two three )
echo ${arr[$(([EMAIL PROTECTED]))]}

At least you can leave out the $((...)) construct, this is implicit.

Andreas.

-- 
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: last element of an array

2007-05-24 Thread Poor Yorick

  
   If there is not currently a friendlier syntax for this, might I suggest:
  
   ${arr[-1]}
  
  What's wrong with echo [EMAIL PROTECTED]: -1} ?
  

I assume this syntax is new since 2.05b.01(1), which is what I currently have 
access to.  I did check the latest what's new before posting, but it must 
have been in a previous one. Thanks.

-- 
Poor Yorick


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: Timing an operation

2007-05-24 Thread Paul Jarc
Matthew_S [EMAIL PROTECTED] wrote:
 Can i have something like;

 if 
 difference between dates 5seconds 
 echo fail
 fi

date1=`perl -e 'print time()'`
...
date2=`perl -e 'print time()'`
interval=`expr $date2 - $date1`
if test 5 -gt $interval; then
  echo fail
fi

On some systems, you could also use date +%s instead of perl, if you
prefer.


paul


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: Timing an operation

2007-05-24 Thread Chet Ramey
Paul Jarc wrote:

 date1=`perl -e 'print time()'`
 ...
 date2=`perl -e 'print time()'`
 interval=`expr $date2 - $date1`

This general approach can be used without invoking any external programs:

date1=$SECONDS
...
date2=$SECONDS
interval=$(( $date2 - $date1 ))

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
   Live Strong.  No day but today.
Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://cnswww.cns.cwru.edu/~chet/


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash