function grammar

2010-07-18 Thread Linda Walsh
from man bash, to define a function use; "function" "name" OR "name" () right? And Compound Commands are: ( ) { ; ) (( expression )) [[ expression ]] ...et al so why do I get a syntax error for function good_dir [[ -n $1 && -d $1 && -r $1 && -x $1 ]] bash: syntax error near u

Re: Bad performance for substring replacement by pattern

2010-07-18 Thread Linda Walsh
Yi Yan wrote: Hi, I used the following Bash script to test substring replacement operator. It is performance get worse very quickly with the increasing of the string length. I test the script with Bash(4.1) on Debian Linux machine. See the execution time difference by increasing

How to input ^J?

2010-07-18 Thread Peng Yu
Hi, I have some filenames that have the character ^J. I can not figure out a way to input such a character. Does anybody know if it is possible to input ^J? -- Regards, Peng

Re: How to input ^J?

2010-07-18 Thread Bob Proulx
Peng Yu wrote: > I have some filenames that have the character ^J. I can not figure out > a way to input such a character. Does anybody know if it is possible > to input ^J? Several ways. One is you can quote the characters "verbatim" with C-v before the character. As in C-v C-j. (A.K.A. ^v ^j)

Re: How to input ^J?

2010-07-18 Thread John Reiser
> Lastly since ^J is a newline you can generate one with echo "\n". That does not work in bash-4.x. Firstly, by default the bash builtin 'echo' supplies a trailing newline. Secondly, backslash translation requires the option "-e". $ echo "\n" \n $ echo "\n" | od -c 000 \ n \n 003 $

Re: function grammar

2010-07-18 Thread Clark J. Wang
On Mon, Jul 19, 2010 at 2:53 AM, Linda Walsh wrote: > > > from man bash, to define a function use; > > "function" "name" > OR > "name" () > > right? > > And Compound Commands are: > > ( ) > { ; ) > (( expression )) > [[ expression ]] > ...et al > > so why do I get a syntax error for >

Re: function grammar

2010-07-18 Thread Linda Walsh
The curly brackets are suposed to be optional. They are line "2" of the Compound commands list below... Clark J. Wang wrote: On Mon, Jul 19, 2010 at 2:53 AM, Linda Walsh > wrote: from man bash, to define a function use; "function" "name" OR "name" (

Re: function grammar

2010-07-18 Thread Jan Schampera
Linda Walsh wrote: The curly brackets are suposed to be optional. They are line "2" of the Compound commands list below... Don't ask me why, but it works when you don't use the "function" keyword, but "()" instead: foo() [[ 1 ]] Might be a parsing bug, though you shouldn't use "function" at

Re: function grammar

2010-07-18 Thread Ken Irving
On Sun, Jul 18, 2010 at 11:53:02AM -0700, Linda Walsh wrote: > > from man bash, to define a function use; > > "function" "name" > OR > "name" () > > right? > > And Compound Commands are: > > ( ) > { ; ) > (( expression )) > [[ expression ]] > ...et al > > so why do I get a syntax