Re: bash accepts script with incorrect syntax and goes into infinite loop

2009-10-09 Thread Dave B
On Friday 09 October 2009, Pierre Gaston wrote: Repeat-By: printf '%s\n%s\n' foo bar | while read NAME; echo NAME=$NAME do echo blah done Not sure what is the incorrect syntax, and it seems normal that it goes into an infinite loop since echo

Re: bash accepts script with incorrect syntax and goes into infinite loop

2009-10-09 Thread Dave B
On Friday 09 October 2009, Pierre Gaston wrote: Well, it seems to me (and as stated in the bug report) that a do should follow the while read NAME;. the while syntax is like this: while list; do list; done and the manual says A sequence of one or more newlines may appear in a list

Re: Real easy questions. Please answer

2009-09-25 Thread Dave B
On Friday 25 September 2009 05:24:04 eatsubway wrote: 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

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 k' ~$

Re: 'time' redirection, and pipe redirections in general

2009-07-25 Thread Dave B
On Saturday 25 July 2009, Linda Walsh wrote: AFAIK, I'm still screwed if I want to create more than one pipe for outputs -- either sending stderr to one pipe and stdout to another, OR a way of even doing what tee does, but built into the shell, so I could, using the building tee, a file

Re: Bash script file naming problem?

2009-07-25 Thread Dave B
On Saturday 25 July 2009, michael rice wrote: Is there a problem with naming a bash script file script? I'm using Fedora 11. script is most likely the name of a command installed on your system (on mine, it's /usr/bin/script). Try man script and see. So if you really want to call your script

Re: regarding 'time' builtin

2009-07-17 Thread Dave B
On Friday 17 July 2009, Linda Walsh wrote: where does the output from the 'time' command go I.e. if I wanted to pipe the output to a prog or file, how would I go about doing it? Please see http://mywiki.wooledge.org/BashFAQ/032 -- D.

Re: Possible Feature Requests (unsource, exchange)

2009-07-07 Thread Dave B
On Tuesday 07 July 2009, Christopher Roy Bratusek wrote: Hi all, what I'm currently missing are the following two things (I'm not 100% sure if they are not available): unsource: the opposite of source (while source is making functions publically available, unsource would remove them)

Re: Howto set a Readline variable (not in the init file!)?

2009-01-12 Thread Dave B
Andi Bachmann wrote: Hello I'm looking for a way to set a Readline variable, but without editing the init (~/.inputrc or /etc/inputrc) file. E.g., I'd like to have set show-all-if-ambiguous on The thing is that I have to login to some remote server with a login that I share

Re: $(grep anycommand anyfile) fail

2008-12-24 Thread Dave B
BlackEnvil wrote: Description: using ` ` or $() with command that use dirnames with spaces fail. there are diferent dirnames with this problem, and different situations that cause these errors, not only with ls and not only with grep. bye Repeat-By: [blacken...@space_star ~]$ cd

Re: Formating variable with caracter and date.

2008-12-12 Thread Dave B
Dolphin06 wrote: Hello all, I would like to give a variable a value which have a format like this one: 3 letters-date-digit date should be yymmdd. Date of the day by default. How would i do this, i know the date command is date +%y-%m-%d, but i dont know the syntax for mixing letters

Re: Maximum limit of pipes in a single command ?

2008-08-28 Thread Dave B
Keshetti Mahesh wrote: Hi all, Can anyone tell me what is the maximum limit of number of pipes that can be opened through a single command ? e.g; # cmnd ||| .| For what is worth, on my system (bash 3.2.33(1)-release) I can have 3332 pipes before bash gives

Re: Equivalent of ksh, zsh {N}[WORD] ?

2008-08-26 Thread Dave B
Pierre Gaston wrote: On Tue, Aug 26, 2008 at 5:41 AM, R. Bernstein [EMAIL PROTECTED] wrote: Both zsh and ksh have a way to open a file or duplicate a file descriptor and let the interpreter pick the descriptor saving the newly-allocated file descriptor number in a variable. In

Re: Equivalent of ksh, zsh {N}[WORD] ?

2008-08-26 Thread Dave B
Pierre Gaston wrote: I think he refers to the fact that, with ksh, you can do for instance $ exec {fd}0 $ echo $fd 10 $ exec {fd1}0 $ echo $fd1 11 I didn't try on zsh, but with bash you get: $ exec {fd}0 -bash: exec: {fd}: not found ah sorry I didn't know this syntax on which

Re: 'read' primitive

2008-08-22 Thread Dave B
Bob Proulx wrote: To get the entire line verbatim you would need to use the $REPLY variable. Or also use IFS= read -r foo bar -- D.

Re: How to create parameterized aliases in bashrc

2008-07-26 Thread Dave B
Aman Jain wrote: Hi I would like to create an alias to show Nth line of a file. I tried something like alias shline='head -$1 $2 | tail -1' #$1 is the line number and $2 is the filename # Usage should be : $shline 5 file.txt

Re: Regular expression match operation with character classes fails in bash 3.2

2008-06-28 Thread Dave B
John E. Wulff wrote: I have just updated from openSUSE 10.2 to openSUSE 11.0 Linux. My backup shell script is now broken. I tracked the problen down to the latest version of bash. The relatively new binary operator =~ does not match a regular expression which contains a

Re: Strange return codes of continue

2008-06-27 Thread Dave B
Roman Rakus wrote: This is realy strange. I have two examples First: while [ 1 ]; do while [ 1 ]; do continue 0 done done echo $? Second: while [ 1 ]; do while [ 1 ]; do continue 0 done echo $? done echo $? In first case I have echoed 1. And I am

Re: [[ ... =~ ... ]] is broken when RHS is quoted

2008-06-22 Thread Dave B
Alexis Huxley wrote: Description: [[ ... =~ ... ]] is broken when RHS is quoted AFAICT that seems to have changed from 3.2alpha. According to the changelog, from version 3.2alpha, Quoting the string argument to the [[ command's =~ operator now forces string matching, as with the other

Re: [[ ... =~ ... ]] is broken when RHS is quoted

2008-06-22 Thread Dave B
Alexis Huxley wrote: Quote removal means that, as usual, quotes do not form part of the arguments, they merely serve to delimit the arguments, I take it. Words between [[ and ]] ... quote removal performed means on *all* words between [[ and ]] I take it. Hmm ... No, that can't be right

Re: unexpected behavior of 'read' builtin

2008-05-24 Thread Dave B
On Saturday 24 May 2008 02:44, Juliano F. Ravasi wrote: Description: I got bitten by two unexpected (and undocumented) behaviors of the 'read' builtin. The first one is that it doesn't seem to handle word separators equally, making distinction when spaces and non-space separators are

Re: finding the index at which two strings differ

2008-05-07 Thread Dave B
On Tuesday 6 May 2008 22:33, Dave B wrote: while [ $i -le $((${#a}-1)) ] [ $i -le $((${#b}-1)) ]; do while [ $i -lt ${#a} ] [ $i -lt ${#b} ]; do -- D.

Re: Bash messes up spaces in command line agruments.

2008-05-07 Thread Dave B
On Tuesday 6 May 2008 16:20, Herrmann, Justin wrote: Description: When I try to pass strings inside double or single quotes as command line arguments to my Bash script, leading spaces, trailing spaces, and multiple grouped embedded spaces are removed from the string. This also prevents me

Re: Bash messes up spaces in command line agruments.

2008-05-07 Thread Dave B
On Wednesday 7 May 2008 14:54, Dave B wrote: $ ./startup ' some words ' 1 0 |./startup| 0 |./startup| 1 |some words | 1 | some words | # ' some words ' This should have been $ ./startup ' some words

Re: at which byte do two strings differ

2008-05-06 Thread Dave B
On Tuesday 6 May 2008 07:53, Nathan Coulter wrote: Looking for a simple ways to output the byte at which two strings differ. Here is one: cmp (echo hello) (echo help) | cut -d' ' -f5 | tr -d , Any other suggestions? I can't see how this pertains to gnu.bash.bug, however try this: echo

Re: finding the index at which two strings differ

2008-05-06 Thread Dave B
On Tuesday 6 May 2008 21:29, Bob Proulx wrote: I can't think of any way to do this natively in bash Well, there's a loop solution, but it's a bit awkward: a=help; b=hello; i=0 while [ $i -le $((${#a}-1)) ] [ $i -le $((${#b}-1)) ]; do if [ ${a:${i}:1} = ${b:${i}:1} ]; then i=$((i+1))