Real easy questions. Please answer

2009-09-24 Thread eatsubway
sry i have a stupid question. I have a variable and need to know how many items are in it. for example: variable="abc xyz foo" what program can i call to print out 3 right now im doing this... Counter() { echo $# } Counter $IDs but that just seems stupid -- View this message in contex

Re: Strange compgen behaviour

2009-09-24 Thread Mathias Dahl
> ...but then I have to shell quote the file name myself to handle > spaces, brackets of various sorts, comma characters etc. Will hunt for > such a function and see. There are all sorts of crazy helper functions > in /etc/bash_completion, of which I barely understand anything. I did not find any

Re: Strange compgen behaviour

2009-09-24 Thread Mathias Dahl
> Hm, compgen appears to behave strange if words contain whitespace. > However, you don't need it, as you build the list yourself. Try this: > >   _mm2() { >       local cur files >       cur=${COMP_WORDS[COMP_CWORD]} >       files=$(find /home/mathias/Videos/movies/ -iname "$cur*.avi" -type > f -p

Re: Bug in array populating does not respect quotes

2009-09-24 Thread Chris F.A. Johnson
On Thu, 24 Sep 2009, David Martin wrote: > 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' > -DCO

Re: Bug in array populating does not respect quotes

2009-09-24 Thread Dave B
On Thursday 24 September 2009 16:38:12 David Martin wrote: > Description: > When populating an array from a string in a variable does not > handle quotes. > > Repeat-By: > > ~$ declare -a samplearray > ~$ samplearray=( x y 'z k') > ~$ echo ${samplearray[2]} > z k > ~$ samplestring="x y 'z

Bug in array populating does not respect quotes

2009-09-24 Thread David Martin
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' -DLOCALEDI$ uname output: Linux bristol 2

Re: bash 4 parse error on here-document in $()

2009-09-24 Thread Martin Sebor
Thank you for setting me straight! I had checked the POSIX spec before sending the report but missed the part about the delimiter having to be immediately followed by newline. Martin On 09/24/2009 06:39 AM, Chet Ramey wrote: Machine Type: i386-redhat-linux-gnu Bash Version: 4.0 Patch Level: 23

Re: Strange compgen behaviour

2009-09-24 Thread Chris F.A. Johnson
On Thu, 24 Sep 2009, Bernd Eggink wrote: > Chet Ramey schrieb: > > > Hm, compgen appears to behave strange if words contain whitespace. > > > > Well, it splits the argument to -W on $IFS as documented. What other > > strange behavior do you see? > > For example, this: > > function _aha >

Re: string format

2009-09-24 Thread mahaveer darade
given below will work except tab at beginning. echo "Hello, how are you doing today?" | tr -s " " "\n" Thanks, Mahaveer +91 9052000707 On Thu, Sep 24, 2009 at 12:33 AM, eatsubway wrote: > > hello, i have a simple question. I have a string which i would like to > format by replacing spaces

Re: Strange compgen behaviour

2009-09-24 Thread Chet Ramey
Bernd Eggink wrote: > Chet Ramey schrieb: >>> Hm, compgen appears to behave strange if words contain whitespace. >> >> Well, it splits the argument to -W on $IFS as documented. What other >> strange behavior do you see? > > For example, this: > > function _aha > { > local list=

Re: Strange compgen behaviour

2009-09-24 Thread Bernd Eggink
Chet Ramey schrieb: Hm, compgen appears to behave strange if words contain whitespace. Well, it splits the argument to -W on $IFS as documented. What other strange behavior do you see? For example, this: function _aha { local list="a b:c d:e f" COMPREPLY=($(IFS=: co

Re: Change in behaviour regarding subshell handling?

2009-09-24 Thread Chet Ramey
> Thanks for the confirmation. Maybe CHANGES can be updated to list all > the changes that were made as a consequence of the Austin Group's > interpretation. Here's the new description of "set -e": -e When this option is on, when any command fails (for any of the reasons listed in [xref

Re: Change in behaviour regarding subshell handling?

2009-09-24 Thread Martin Michlmayr
* Chet Ramey [2009-09-24 08:29]: > > l. Changed behavior of shell when -e option is in effect to reflect > > consensus > > of Posix shell standardization working group. > > This behavior is one of the consequences of the Austin Group's interpretation. > Failures of user-specified subshe

Re: Strange compgen behaviour

2009-09-24 Thread Chet Ramey
> Hm, compgen appears to behave strange if words contain whitespace. Well, it splits the argument to -W on $IFS as documented. What other strange behavior do you see? Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates

Re: bash 4 parse error on here-document in $()

2009-09-24 Thread Chet Ramey
> Machine Type: i386-redhat-linux-gnu > > Bash Version: 4.0 > Patch Level: 23 > Release Status: release > > Description: > Bash 4.0 errors on a here-document enclosed in $(). For example: > x=$(cat < foo > bar > EOF) > Ctrl+D > -bash: unexpected EOF while

Re: Change in behaviour regarding subshell handling?

2009-09-24 Thread Chet Ramey
> I noticed that bash has changed behaviour regarding subshell handling, > breaking a script of mine. Now a script with -e fails when a subshell > fails whereas it didn't before. I looked at the CHANGES file and > couldn't find anything about this, so I wanted to ask if this change > was intentio

Re: Strange compgen behaviour

2009-09-24 Thread Bernd Eggink
Mathias Dahl schrieb: It depends heavily on how the variables IFS and zf are set. From 'man bash': -W wordlist The wordlist is split using the characters in the IFS special variable as delimiters, and each resultant word is expanded. The possible completions are the members of the