Random loss of history entries

2007-11-10 Thread Patrick J. Timlick
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib
 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -m32
-march=i386 -mtune=pentium4
uname output: Linux rat 2.6.9-42.0.10.ELsmp #1 SMP Tue Feb 27 08:38:56
CST 2007 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 3.0
Patch Level: 15
Release Status: release

Description:
When using bash command history heavily, with long lines, and command
review and reuse, command history becomes useless, possibly being
reset way back in time.
There is more detail at http://shallowsky.com/blog/linux/, the essence
of which is repeated below:
"Say I type some longish command. After it runs, I hit return a couple
of times, wait a while, do a couple of other things, then decide I
want to call that command back from history so I can run something
similar, maybe with the filename changed or a different flag. I ctrl-P
or up-arrow ... and the command isn't there!

If I type history at this point, I'll see most of my command history
... with an empty line in place of the line I was hoping to repeat.
The command is gone. My only option is to remember what I typed, and
type it all again."


Repeat-By:
I have not been able to discern a pattern, except that it happens at
very inconvenient times.




Array Elements with Spaces

2007-11-10 Thread Michael Potter
Group,

I have having a problem with spaces in individual elements of an array.

The space causes a single element to be seen as multiple elements.

Here is a sample run:

-
[EMAIL PROTECTED]:~/bin> ./arraywithspace.sh
3.1.17(1)-release
got 6 parms
parm: arg1
parm: arg2
parm: arg
parm: 3
parm: arg
parm: four
[EMAIL PROTECTED]:~/bin> cat ./arraywithspace.sh
#!/bin/bash

declare -a Arguments=("arg1" "arg2" "arg 3" "arg four")

function countparms
{
   echo "got $# parms"

   while (($# != 0 ))
   do
  echo "parm: $1"
  shift
   done
}

echo $BASH_VERSION

countparms ${Arguments[*]}

--

The real problem I am having is using the array as a list of arguments
to a command, maybe something like this:

grep -i mypattern ${FileList[*]}

-- 
potter




Re: Array Elements with Spaces

2007-11-10 Thread Andreas Schwab
"Michael Potter" <[EMAIL PROTECTED]> writes:

> countparms ${Arguments[*]}

Use "[EMAIL PROTECTED]" instead (including the quotes).  See node Arrays
in the Bash docs.

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




Re: Array Elements with Spaces

2007-11-10 Thread Michael Potter
Thanks,

That fixed it.

For the benefit of others...
I ran my test program on a couple different versions of bash (including 2.x)
and It seems that this behavior (combination of quotes and * versus @)
changes based on the version of bash, and not just between 2.x and 3.x.  I
did not do an exhaustive test because this solution will work for me.

-- 
potter

On Nov 10, 2007 12:27 PM, Andreas Schwab <[EMAIL PROTECTED]> wrote:

> "Michael Potter" <[EMAIL PROTECTED]> writes:
>
> > countparms ${Arguments[*]}
>
> Use "[EMAIL PROTECTED]" instead (including the quotes).  See node Arrays
> in the Bash docs.
>
> 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."
>