How to include `$$' literally in the PS1 prompt?

2007-09-30 Thread Clark J. Wang
I want to show the bash PID in my prompt. For example, if the PID of shell is 12345 I want the prompt to look like this: [$$=12345 ~/tmp] # If I set PS1 like this: PS1='[$$=$$ \w] \$ ' then both `$$' would be expanded to 12345. If I set PS1 like this: PS1='[\$\$=$$ \w] \$ ' then `\$\$' would

Re: `set completion-ignore-case on' does not work well for the first word on command line

2008-02-14 Thread Clark J. Wang
On Fri, Feb 15, 2008 at 1:45 PM, Jian Wang [EMAIL PROTECTED] wrote: When using Bash, I often turn on the `completion-ignore-case' option of readline. It works fine for most cases but sometimes it does not work as expected when completing the first word on the command line. For example, there

=~ behaves differently in bash 3.2 and 3.0

2008-10-24 Thread Clark J. Wang
In bash 3.0.14, the condition [[ file.txt =~ .*\\.txt\$ ]] returns TRUE but in 3.2.39 it returns FALSE. But with the shopt option `compat31' set it also returns TRUE. Is that reasonable? In the bash manual, `compat31' makes sense only for quoted patterns. The string .*\\.txt\$ is considered to be

Re: =~ behaves differently in bash 3.2 and 3.0

2008-10-30 Thread Clark J. Wang
Thanks for all of your replies. BTW: I didn't find FAQ E14 in 3.2.39's `doc/FAQ' file. It's not updated yet?

[bash 3.2.39] File descriptor 10 is always duplicated from 0 and cannot be closed

2008-10-31 Thread Clark J. Wang
Hi, all: When I was doing some testing I found the file descriptor 10 is always duplicate of fd 0 and it cannot be closed. See the following commands: # echo $BASH_VERSION 3.2.39(1)-release # read line 10 hello--- input from keyboard # echo $line hello # exec 10---- try to close fd 10 #

Re: [bash 3.2.39] File descriptor 10 is always duplicated from 0 and cannot be closed

2008-11-02 Thread Clark J. Wang
On Mon, Nov 3, 2008 at 06:19, Chet Ramey [EMAIL PROTECTED] wrote: Clark J. Wang wrote: When I was doing some testing I found the file descriptor 10 is always duplicate of fd 0 and it cannot be closed. Half right. When a redirection involving fd 0 is evaluated, the shell has to save fd 0

[PATCH] bash-4.0.10: segfault with `; ' at the end of case statement

2009-03-14 Thread Clark J. Wang
With bash version: 4.0.10, the following case statement crashed with segfault: $ cat foo.sh case a in a) echo a ; esac $ bash4 foo.sh a Segmentation fault $ In an interactive shell, that case statement causes current shell to hang with nearly 100% CPU usage. The following patch fixes this

[IGNORE THIS] Just testing if I can post to the list from Google Groups

2009-03-27 Thread Clark J. Wang
See this message? Fine. :)

Bug for brace expansion {01..09..2}

2009-08-28 Thread Clark J. Wang
Bash version: 4.0.28 Steps to reproduce: $ echo {01..10..2} 01 03 05 07 09 $ echo {01..09..2} 1 3 5 7 9--- ??? $ echo {10..01} 10 09 08 07 06 05 04 03 02 01 $ echo {10..01..2} 00010 8 6 4 2--- ??? $

Re: Bash sometimes cannot find aliases

2010-01-28 Thread Clark J. Wang
On Thu, Jan 28, 2010 at 4:55 PM, Dan Zwell dzw...@zwell.net 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'

Any guide about writing my own bash built-in commands?

2010-01-28 Thread Clark J. Wang
Hi all, I want to write my own built-in bash commands but I cannot find any info about that in bash manual. Anyone has any idea? Thanks. -Clark

Re: Any guide about writing my own bash built-in commands?

2010-01-28 Thread Clark J. Wang
On Fri, Jan 29, 2010 at 1:39 PM, Renjun Wang renju...@gmail.com wrote: I just put the shell scripts I write into $PATH,it works well That's not what I want to do. I want to make my own built-in commands (like `alias', `cd') other than external bash scripts. 2010/1/28 Clark J. Wang dearv

Re: Any guide about writing my own bash built-in commands?

2010-01-29 Thread Clark J. Wang
On Fri, Jan 29, 2010 at 2:20 PM, Chris Jones cjns1...@gmail.com wrote: On Thu, Jan 28, 2010 at 08:42:25PM EST, Clark J. Wang wrote: Hi all, I want to write my own built-in bash commands but I cannot find any info about that in bash manual. Anyone has any idea? Never done that myself

Re: Any guide about writing my own bash built-in commands?

2010-02-01 Thread Clark J. Wang
CTRL-C to break it. Then I expected the bash var $? to be 130 (= 128 + SIGINT) but actually $? was 137 (= 128 + 9). So how can I fix it to make $? be 130 when interrupted by CTRL-C? Thanks, Clark On Sat, Jan 30, 2010 at 10:17 PM, Joachim Schmitz nospam.j...@schmitz-digital.de wrote: Clark J

Re: Bash sometimes cannot find aliases

2010-03-30 Thread Clark J. Wang
, Clark J. Wang dearv...@gmail.com wrote: On Thu, Jan 28, 2010 at 4:55 PM, Dan Zwell dzw...@zwell.net wrote: Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64

Re: Bash sometimes cannot find aliases

2010-03-30 Thread Clark J. Wang
Bash 2.05b also reproduces this problem. On Tue, Mar 30, 2010 at 2:36 PM, Clark J. Wang dearv...@gmail.com wrote: Good news: I met this problem again a few minutes ago. Then I looked back to find out what I was doing. After some investigation I could stably reproduce this problem

Re: Bash sometimes cannot find aliases

2010-03-30 Thread Clark J. Wang
On Tue, Mar 30, 2010 at 8:15 PM, Greg Wooledge wool...@eeg.ccf.org wrote: On Tue, Mar 30, 2010 at 02:36:59PM +0800, Clark J. Wang wrote: After some investigation I could stably reproduce this problem by following steps (tested with bash 3.1.17, 3.2.39 and 4.1.0): bash$ alias xx='echo

Strange behavior of IFS?

2010-04-15 Thread Clark J. Wang
Look at following result: # cat foo.sh string=aa:bb:cc oldIFS=$IFS IFS=: for i in $string; do     echo $i done IFS=$oldIFS # bash foo.sh aa bb cc # I don't understand why the $string was still splitted into words since it's double quoted. Anyone can give a reasonable explanation? -Clark

Re: Strange behavior of IFS?

2010-04-15 Thread Clark J. Wang
I see. Thank you. On Thu, Apr 15, 2010 at 10:05 PM, Greg Wooledge wool...@eeg.ccf.org wrote: On Thu, Apr 15, 2010 at 09:58:42PM +0800, Clark J. Wang wrote: # cat foo.sh string=aa:bb:cc oldIFS=$IFS IFS=: for i in $string; do     echo $i done IFS=$oldIFS # bash foo.sh aa bb cc # I

Undocumented usage of printf?

2010-04-15 Thread Clark J. Wang
I saw a printf usage from a Linux forum's post: # printf %d\n 'a 97 # It's really cool but I found no info in bash's manual. Are there any other undocumented interesting features? :)

Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms?

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
:28 AM, Clark J. Wang wrote: In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms? man 1 flock If necessary, you may need to install: ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/ -- Eric Blake ebl...@redhat.com

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
On Fri, Apr 16, 2010 at 12:04 AM, Jan Schampera jan.schamp...@web.dewrote: Clark J. Wang schrieb: In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms? For simple things, which don't need to be 1000% rocksolid, you

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
On Fri, Apr 16, 2010 at 12:57 AM, Bob Proulx b...@proulx.com wrote: Eric Blake wrote: Clark J. Wang wrote: In C code I can use lockf(), flock(), semaphore and mutex for locking / unlocking. Can bash provide some similar mechanisms? man 1 flock If necessary, you may need

Re: Undocumented usage of printf?

2010-04-15 Thread Clark J. Wang
On Thu, Apr 15, 2010 at 11:43 PM, Eric Blake ebl...@redhat.com wrote: On 04/15/2010 08:21 AM, Clark J. Wang wrote: I saw a printf usage from a Linux forum's post: # printf %d\n 'a 97 # POSIX requires this behavior, so you could claim that this serves as documentation: http

Re: Feature request: Can bash provide some mechanism for locking/unlocking?

2010-04-15 Thread Clark J. Wang
On Fri, Apr 16, 2010 at 10:52 AM, Bob Proulx b...@proulx.com wrote: Clark J. Wang wrote: Bob Proulx wrote: There is also 'lockfile' distributed with 'procmail'. By using `lockfile' we must make sure that our script will not crash and the file is unlocked when the script exits. True

Re: How to make a directory name with '/' in it?

2010-05-16 Thread Clark J. Wang
On Sun, May 16, 2010 at 23:47, Peng Yu pengyu...@gmail.com wrote: I tried the following command to create a dir with '/' in the name. But it only create a directory with name 'm'. Is there a way to make a directory with '/' in the name? Seems like Mac OS X can have `/' in directory names.

Re: cd multiple levels up?

2010-06-16 Thread Clark J. Wang
On Sun, Jun 13, 2010 at 7:46 PM, Peng Yu pengyu...@gmail.com wrote: Hello, I frequently need do cd multiple levels up. For example, cd ../.. cd ../../../../ It would be convenient to type something like cd 2 or cd 4. Is there a command for this? -- Regards, Peng My way: I wrote a

Re: cd multiple levels up?

2010-06-16 Thread Clark J. Wang
My way: I wrote a compgen function for cd and it behaves like this: when you type `cd .' on the command line and then press TAB, the command line becomes `cd ../../../../', then you can continue editing it to be `cd ../../../../other-dir/' and press ENTER. I'm against changing the

Re: How not to inherit any environment variable from parent process?

2010-06-22 Thread Clark J. Wang
On Wed, Jun 23, 2010 at 12:32 PM, Peng Yu pengyu...@gmail.com wrote: I use bash --noprofile to start a bash session. Since this doesn't source any profile files, I'd think that no environment variable should be set. But I still see environment variables set. Are they inherit from the parent

Re: Bash cannot kill itself?

2010-06-29 Thread Clark J. Wang
On Wed, Jun 30, 2010 at 12:38 PM, Chris F.A. Johnson ch...@cfajohnson.comwrote: On Wed, 30 Jun 2010, Clark J. Wang wrote: I have a bash script like this: #!/bin/bash trap 'echo killed by SIGALRM; exit 1' ALRM function wait_kill() { sleep 5 kill -ALRM

Re: Bash cannot kill itself?

2010-06-29 Thread Clark J. Wang
On Wed, Jun 30, 2010 at 1:17 PM, Jan Schampera jan.schamp...@web.de wrote: Chris F.A. Johnson wrote: $$ refers to the subshell. There's no subshell here, I think. The background process invoked by . $$ is meant to always report the main shell, I'd guess this is true for this

Re: Bash cannot kill itself?

2010-06-30 Thread Clark J. Wang
On Wed, Jun 30, 2010 at 1:40 PM, Jan Schampera jan.schamp...@web.de wrote: Clark J. Wang wrote: Running a cmd in background (by ) would not create subshell. Simple testing: #!/bin/bash function foo() { echo $$ } echo $$ foo ### END OF SCRIPT ### The 2 $$s output the same

Re: Bash cannot kill itself?

2010-06-30 Thread Clark J. Wang
On Wed, Jun 30, 2010 at 2:52 PM, Pierre Gaston pierre.gas...@gmail.comwrote: On Wed, Jun 30, 2010 at 9:12 AM, Clark J. Wang dearv...@gmail.com wrote: On Wed, Jun 30, 2010 at 1:40 PM, Jan Schampera jan.schamp...@web.de wrote: It just shows that $$ does what it should do, it reports

How to run something before invoking the inputted command?

2010-07-09 Thread Clark J. Wang
For example, in the interactive shell, I want to track the time when every inputted command is invoked. So I want to run a `date' command before actually invoking the inputted command. For now I have to do like this: $ date; command1 $ date; command2 Is there an easy way to do that? -Clark

Re: How to run something before invoking the inputted command?

2010-07-09 Thread Clark J. Wang
On Sat, Jul 10, 2010 at 11:30 AM, Eric Blake ebl...@redhat.com wrote: On 07/09/2010 09:22 PM, Clark J. Wang wrote: For example, in the interactive shell, I want to track the time when every inputted command is invoked. So I want to run a `date' command before actually invoking

Re: How to run something before invoking the inputted command?

2010-07-12 Thread Clark J. Wang
Personally I've never found any use for PROMPT_COMMAND. It seems klunky and awkward. My PS1 depends much on PROMPT_COMMAND. For example, my PROMPT_COMMAND will trim very long $PWD to a shorter one (depends on the window size of current terminal): [r...@server

Re: How to run something before invoking the inputted command?

2010-07-13 Thread Clark J. Wang
On Tue, Jul 13, 2010 at 8:22 PM, Greg Wooledge wool...@eeg.ccf.org wrote: On Tue, Jul 13, 2010 at 11:19:34AM +0800, Clark J. Wang wrote: My PS1 depends much on PROMPT_COMMAND. For example, my PROMPT_COMMAND will trim very long $PWD to a shorter one (depends on the window size of current

Re: BASH ignores language for command completion

2010-07-14 Thread Clark J. Wang
On Wed, Jul 14, 2010 at 10:29 PM, Bruce Korb bk...@vmem.com wrote: I've stripped all LC_* variables plus LANG from my environment: $ env|fgrep LANG $ env|fgrep LC_ $ My understanding: For most time the language/locale is not set through LC_* vars although LC_* vars can override the

Re: function grammar

2010-07-18 Thread Clark J. Wang
On Mon, Jul 19, 2010 at 2:53 AM, Linda Walsh b...@tlinx.org wrote: from man bash, to define a function use; function name compound-command OR name () compound-command right? And Compound Commands are: ( list) { list; ) (( expression )) [[ expression ]] ...et al so why

Re: Issues when func name is the same with an alias

2010-08-04 Thread Clark J. Wang
On Wed, Aug 4, 2010 at 7:03 PM, Marc Herbert marc.herb...@gmail.com wrote: Le 04/08/2010 11:39, Clark J. Wang a écrit : Seems like I must explicitly use the `function' keyword to define foo() for this scenario. Is that the correct behavior? The correct behaviour is simply not to use

Re: Issues when func name is the same with an alias

2010-08-05 Thread Clark J. Wang
On Thu, Aug 5, 2010 at 4:06 PM, Marc Herbert marc.herb...@gmail.com wrote: Le 04/08/2010 15:29, Clark J. Wang a écrit : I do not agree. Aliases are much simpler to use than functions. Please provide examples. The following is a part of my aliases. I'll have to write much more code if I

Re: Issues when func name is the same with an alias

2010-08-05 Thread Clark J. Wang
On Fri, Aug 6, 2010 at 9:54 AM, Chris F.A. Johnson ch...@cfajohnson.comwrote: On Fri, 6 Aug 2010, Clark J. Wang wrote: On Thu, Aug 5, 2010 at 4:06 PM, Marc Herbert marc.herb...@gmail.com wrote: Le 04/08/2010 15:29, Clark J. Wang a écrit : I do not agree. Aliases are much simpler to use

Re: How is $string translated?

2010-08-30 Thread Clark J. Wang
On Mon, Aug 30, 2010 at 7:30 PM, Pierre Gaston pierre.gas...@gmail.comwrote: On Mon, Aug 30, 2010 at 1:35 PM, Clark J. Wang dearv...@gmail.com wrote: The Bash manual says: A double-quoted string preceded by a dollar sign ($) will cause the string to be translated according

Why `echo -n hello | while read v; do echo $v; done' prints nothing?

2010-12-02 Thread Clark J. Wang
Following command also prints nothing, confused :( for ((i = 0; i 10; ++i)); do echo -n $i; done | while read v; do echo $v; done -- Clark

Re: Why `echo -n hello | while read v; do echo $v; done' prints nothing?

2010-12-02 Thread Clark J. Wang
On Thu, Dec 2, 2010 at 11:49 PM, Greg Wooledge wool...@eeg.ccf.org wrote: On Thu, Dec 02, 2010 at 07:04:57PM +0800, Clark J. Wang wrote: Following command also prints nothing, confused :( for ((i = 0; i 10; ++i)); do echo -n $i; done | while read v; do echo $v; done The output from

Re: Making $! and $? searchable in the man page

2011-01-06 Thread Clark J. Wang
On Fri, Jan 7, 2011 at 1:33 AM, Greg Wooledge wool...@eeg.ccf.org wrote: On Thu, Jan 06, 2011 at 10:48:33AM +0100, Vidar Holen wrote: Hi, Finding the meaning of $? and $! in the man page is quite hard for people not familiar with the layout and bash terminology (this frequently comes

Re: help builtin bug ???

2011-01-20 Thread Clark J. Wang
2011/1/20 Sławomir Iwanek slawomir.iwa...@poczta.fm hello, and what about this: $ help () it opens some program in an interactive mode (which one?). It seems like it does not react on any command, like '?', giving the output: bash: błąd składni przy nieoczekiwanym znaczniku `?' (it's

Re: help's blank lines have four spaces appended

2011-02-11 Thread Clark J. Wang
On Fri, Feb 11, 2011 at 11:16 PM, Chet Ramey chet.ra...@case.edu wrote: On 2/11/11 4:02 AM, Clark J. Wang wrote: On Mon, Feb 7, 2011 at 12:01 AM, Chet Ramey chet.ra...@case.edu mailto:chet.ra...@case.edu wrote: On 2/6/11 2:01 AM, jida...@jidanni.org mailto:jida...@jidanni.org wrote

Re: Don't show help of `readonly' and `readarray' when I run `help read'

2011-02-11 Thread Clark J. Wang
I forgot to reply to all On Fri, Feb 11, 2011 at 11:15 PM, Chet Ramey chet.ra...@case.edu wrote: On 2/11/11 3:53 AM, Clark J. Wang wrote: On Thu, Feb 10, 2011 at 10:21 PM, Chet Ramey chet.ra...@case.edu mailto:chet.ra...@case.edu wrote: On 2/10/11 4:03 AM, Clark J. Wang wrote

[bash4.2] ${v//[/} bug?

2011-02-15 Thread Clark J. Wang
For following script: var='[hello' echo ${var//[/} With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash 4.2 with compat41 on still outputs [hello . Bug? Or Bug fixed? -- Clark

Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Clark J. Wang
On Wed, Feb 16, 2011 at 9:20 AM, Chet Ramey chet.ra...@case.edu wrote: On 2/15/11 6:18 AM, Clark J. Wang wrote: For following script: var='[hello' echo ${var//[/} With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash 4.2 with compat41 on still outputs [hello

Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Clark J. Wang
On Wed, Feb 16, 2011 at 9:59 AM, Chet Ramey chet.ra...@case.edu wrote: On 2/15/11 6:18 AM, Clark J. Wang wrote: For following script: var='[hello' echo ${var//[/} With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash 4.2 with compat41 on still outputs [hello

Re: typeset -r prevents local variable of same name.

2011-02-16 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 11:13 AM, Chet Ramey chet.ra...@case.edu wrote: On 2/13/11 3:17 PM, ste...@syslang.net wrote: Configuration Information [Automatically generated, do not change]: Machine: i386 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash'

[bash 4.2] In vi mode, cc failed to change the whole line

2011-02-16 Thread Clark J. Wang
For example, in vi insert mode, I first enter a command like this: # hello world Then I press ESC and type cc, the cursor just moves to the beginning (under the char `h') and the whole line is not emptied. If I type more chars after cc, only the first `h' char is replaced and following `ello

Do more testing before a release?

2011-02-16 Thread Clark J. Wang
I know little about open source development process (and control?). I just don't know where to get the bash code (like CVS, SVN respository) before it's released. I think it's better to make it open to more people so everyone can help review and test before a stable release. -- Clark

Re: Do more testing before a release?

2011-02-16 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 1:38 PM, Mike Frysinger vap...@gentoo.org wrote: On Wednesday, February 16, 2011 23:51:16 Clark J. Wang wrote: I know little about open source development process (and control?). I just don't know where to get the bash code (like CVS, SVN respository) before it's

Re: [bash 4.2] In vi mode, cc failed to change the whole line

2011-02-16 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 12:43 PM, Clark J. Wang dearv...@gmail.com wrote: # ldd /usr/local/bash-4.2.0/bin/bash linux-gate.so.1 = (0xb773) libncurses.so.5 = /lib/libncurses.so.5 (0xb76ec000) libdl.so.2 = /lib/i686/cmov/libdl.so.2 (0xb76e8000) libc.so.6

Why escape char `:' with `\' when auto completing filenames?

2011-02-17 Thread Clark J. Wang
For example: # touch ifcfg-eth-id-00:0c:29:b5:71:d2 # ls ifcfgTAB After pressing the TAB the command line will become to: # ls ifcfg-eth-id-00\:0c\:29\:b5\:71\:d2 That's a bit annoying. I think char `:' is not special in bash. Any reasonable consideration for the behavior? -- Clark

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-17 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 5:00 PM, Andreas Schwab sch...@linux-m68k.orgwrote: Clark J. Wang dearv...@gmail.com writes: I think char `:' is not special in bash. $ printf %q\n $COMP_WORDBREAKS $' \t\n\'=;|(:' I don't think that explain the issue. Try like this (tested with 4.2

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-17 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 6:19 PM, Andreas Schwab sch...@linux-m68k.orgwrote: Clark J. Wang dearv...@gmail.com writes: On Thu, Feb 17, 2011 at 5:00 PM, Andreas Schwab sch...@linux-m68k.org wrote: Clark J. Wang dearv...@gmail.com writes: I think char `:' is not special in bash

Inconsistence when checking if a pattern is quoted or not for `==' and `=~' in [[ ]]

2011-02-17 Thread Clark J. Wang
See following script output: bash-4.2# cat quoted-pattern.sh [[ .a == \.a* ]] echo 1 # not quoted [[ aa =~ \.a* ]] echo 2 # quoted [[ aa =~ \a. ]] echo 3 # not quoted [[ aa =~ \a\. ]] echo 4 # quoted bash-4.2# bash42 quoted-pattern.sh 1 3 bash-4.2# From my understanding 1 2 3 4 should

Re: Inconsistence when checking if a pattern is quoted or not for `==' and `=~' in [[ ]]

2011-02-17 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 9:20 PM, Andreas Schwab sch...@linux-m68k.orgwrote: Clark J. Wang dearv...@gmail.com writes: See following script output: bash-4.2# cat quoted-pattern.sh [[ .a == \.a* ]] echo 1 # not quoted [[ aa =~ \.a* ]] echo 2 # quoted [[ aa =~ \a. ]] echo 3

Re: Inconsistence when checking if a pattern is quoted or not for `==' and `=~' in [[ ]]

2011-02-17 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 7:09 PM, Clark J. Wang dearv...@gmail.com wrote: See following script output: bash-4.2# cat quoted-pattern.sh [[ .a == \.a* ]] echo 1 # not quoted [[ aa =~ \.a* ]] echo 2 # quoted [[ aa =~ \a. ]] echo 3 # not quoted [[ aa =~ \a\. ]] echo 4 # quoted bash

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-17 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 9:10 PM, Andreas Schwab sch...@linux-m68k.orgwrote: Clark J. Wang dearv...@gmail.com writes: On Thu, Feb 17, 2011 at 6:19 PM, Andreas Schwab sch...@linux-m68k.org wrote: Clark J. Wang dearv...@gmail.com writes: On Thu, Feb 17, 2011 at 5:00 PM, Andreas Schwab

Re: Inconsistence when checking if a pattern is quoted or not for `==' and `=~' in [[ ]]

2011-02-17 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 11:02 PM, Greg Wooledge wool...@eeg.ccf.org wrote: On Thu, Feb 17, 2011 at 10:56:21PM +0800, Clark J. Wang wrote: The point is: ``Any part of the pattern may be quoted to force it to be matched as a string.'' And backslash is one of bash's quoting chars

Re: Inconsistence when checking if a pattern is quoted or not for `==' and `=~' in [[ ]]

2011-02-17 Thread Clark J. Wang
On Thu, Feb 17, 2011 at 11:04 PM, Andreas Schwab sch...@linux-m68k.orgwrote: Clark J. Wang dearv...@gmail.com writes: The point is: ``Any part of the pattern may be quoted to force it to be matched as a string.'' it == part of the pattern. So I've always been misunderstanding

Re: [bash 4.2] `declare -g' bug?

2011-02-17 Thread Clark J. Wang
On Fri, Feb 18, 2011 at 8:45 AM, Chet Ramey chet.ra...@case.edu wrote: The -g option exists solely to create variables at the global scope. The intent is that functions be able to declare global variables with attributes if they desire. It doesn't change the scoping rules or variable

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-18 Thread Clark J. Wang
On Fri, Feb 18, 2011 at 5:38 PM, Andreas Schwab sch...@linux-m68k.orgwrote: Maarten Billemont lhun...@gmail.com writes: Why are we escaping all word break characters? rm file:name and rm file\:name are effectively identical, I'm not sure I see the need for escaping it. How do you

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-18 Thread Clark J. Wang
On Fri, Feb 18, 2011 at 6:36 PM, Andreas Schwab sch...@linux-m68k.orgwrote: Clark J. Wang dearv...@gmail.com writes: On Fri, Feb 18, 2011 at 5:38 PM, Andreas Schwab sch...@linux-m68k.org wrote: Maarten Billemont lhun...@gmail.com writes: Why are we escaping all word break characters

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-18 Thread Clark J. Wang
On Fri, Feb 18, 2011 at 6:21 PM, Clark J. Wang dearv...@gmail.com wrote: On Fri, Feb 18, 2011 at 6:02 AM, Chet Ramey chet.ra...@case.edu wrote: For pete's sake. If you don't think they should be word break characters, modify the value of COMP_WORDBREAKS. For the record, @ causes a word

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-18 Thread Clark J. Wang
On Fri, Feb 18, 2011 at 6:48 PM, Pierre Gaston pierre.gas...@gmail.comwrote: On Fri, Feb 18, 2011 at 12:17 PM, Clark J. Wang dearv...@gmail.comwrote: On Fri, Feb 18, 2011 at 5:38 PM, Andreas Schwab sch...@linux-m68k.org wrote: Maarten Billemont lhun...@gmail.com writes: Why are we

Re: [bash 4.2] `declare -g' bug?

2011-02-18 Thread Clark J. Wang
On Fri, Feb 18, 2011 at 9:35 PM, Greg Wooledge wool...@eeg.ccf.org wrote: On Fri, Feb 18, 2011 at 11:25:48AM +0800, Clark J. Wang wrote: A global var can always be declared out of a func (usually at the beginning of the script) so what's the main intention of introducing a new `-g' option

Re: Inconsistence when checking if a pattern is quoted or not for `==' and `=~' in [[ ]]

2011-02-18 Thread Clark J. Wang
to understand. -- Clark J. Wang

Re: [bash4.2] ${v//[/} bug?

2011-02-20 Thread Clark J. Wang
On Sat, Feb 19, 2011 at 1:02 PM, Chet Ramey chet.ra...@case.edu wrote: On 2/15/11 10:16 PM, Clark J. Wang wrote: On Wed, Feb 16, 2011 at 9:59 AM, Chet Ramey chet.ra...@case.edu mailto:chet.ra...@case.edu wrote: On 2/15/11 6:18 AM, Clark J. Wang wrote: For following script

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-20 Thread Clark J. Wang
On Mon, Feb 21, 2011 at 9:21 AM, Chet Ramey chet.ra...@case.edu wrote: On 2/18/11 6:52 AM, Clark J. Wang wrote: Sth was wrong for my testing. I removed @ from COMP_WORDBREAKS but afterwards one bind command (bind set bell-style none) added @ back. I can't reproduce this: $ echo

Re: Why escape char `:' with `\' when auto completing filenames?

2011-02-20 Thread Clark J. Wang
On Mon, Feb 21, 2011 at 9:21 AM, Chet Ramey chet.ra...@case.edu wrote: On 2/18/11 6:52 AM, Clark J. Wang wrote: Sth was wrong for my testing. I removed @ from COMP_WORDBREAKS but afterwards one bind command (bind set bell-style none) added @ back. I can't reproduce this: $ echo

``complete -b'' does not include ``coproc''

2011-02-21 Thread Clark J. Wang
Tested with 4.2: bash-4.2# complete -b help bash-4.2# help coTABTAB command compgen complete compopt continue bash-4.2# -- Clark J. Wang

Re: ``complete -b'' does not include ``coproc''

2011-02-21 Thread Clark J. Wang
On Mon, Feb 21, 2011 at 4:21 PM, Pierre Gaston pierre.gas...@gmail.comwrote: On Mon, Feb 21, 2011 at 10:12 AM, Clark J. Wang dearv...@gmail.comwrote: Tested with 4.2: bash-4.2# complete -b help bash-4.2# help coTABTAB command compgen complete compopt continue bash-4.2

Re: ``complete -b'' does not include ``coproc''

2011-02-21 Thread Clark J. Wang
On Mon, Feb 21, 2011 at 10:26 PM, Chet Ramey chet.ra...@case.edu wrote: On 2/21/11 3:55 AM, Clark J. Wang wrote: And even ``helptopic'' does not show ``coproc'' either: # compgen -A helptopic co command compgen complete compopt continue # Should ``coproc'' be included

Re: Question. Autocomplete paths starting with %.

2011-02-22 Thread Clark J. Wang
=$1 cur=$2 pre=$3 if [[ $cur = % ]]; then COMPREPLY[0]='it-works' fi } complete -F _compgen_foo foo bash# source compgen-example.sh bash# foo %TAB-- Press TAB here bash# foo it-works-- `%' will be expanded like this -- Clark J. Wang

Re: bash tab variable expansion question?

2011-02-25 Thread Clark J. Wang
not be escaped here which is different from pathname completion. -- Clark J. Wang

Re: bash tab variable expansion question?

2011-02-25 Thread Clark J. Wang
Libvirt virtualization library http://libvirt.org -- Clark J. Wang

Re: bash tab variable expansion question?

2011-02-27 Thread Clark J. Wang
completely different. -- Clark J. Wang

Re: variable name and its' value are the same characters causes recursion error

2011-03-09 Thread Clark J. Wang
before. :) For example: unset a; declare a=a; [[ a -lt 3 ]]; echo $? bash: [[: a: expression recursion level exceeded (error token is a) 1 Shouldn't the return code from this expression be 2, rather than 1? Thank you. Peg -- Clark J. Wang

Re: variable name and its' value are the same characters causes recursion error

2011-03-09 Thread Clark J. Wang
here. Does POSIX require that? For example: unset a; declare a=a; [[ a -lt 3 ]]; echo $? bash: [[: a: expression recursion level exceeded (error token is a) 1 Shouldn't the return code from this expression be 2, rather than 1? Thank you. Peg -- Clark J. Wang

Re: case modification won't work with pattern

2011-03-10 Thread Clark J. Wang
replace the first a to uppercase: Abcabc -- correct replace all a to uppercase: AbcAbc-- correct Repeat-By: -- Jerry Wang jerry.j.w...@alcatel-lucent.com -- Clark J. Wang

Re: case modification won't work with pattern

2011-03-10 Thread Clark J. Wang
a to uppercase: Abcabc -- correct replace all a to uppercase: AbcAbc-- correct Repeat-By: -- Jerry Wang jerry.j.w...@alcatel-lucent.com -- Clark J. Wang

Re: case modification won't work with pattern

2011-03-10 Thread Clark J. Wang
the ^. If the character matches the glob, it gets capitalized. No single character is ever going to match the glob ab, because it's two characters long. -- Clark J. Wang

Re: Hightlighting in bash

2011-03-10 Thread Clark J. Wang
disciplines figure that bit out. This would be nice because it would allow one to quickly identify and isolate potentially detrimental error messages from mundane but profuse output that logs commands being invoked, etc. Does this seem doable? Thanks, -Philip -- Clark J. Wang

Re: case modification won't work with pattern

2011-03-10 Thread Clark J. Wang
the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) -- Clark J. Wang

Re: case modification won't work with pattern

2011-03-10 Thread Clark J. Wang
On Fri, Mar 11, 2011 at 11:33 AM, Chet Ramey chet.ra...@case.edu wrote: On 3/10/11 9:04 PM, Clark J. Wang wrote: Agree. Almost all of the poeple around me don't understand why it works that way. Maybe some background of the feature requirement can help us to understand better

[suggestion] Also document users' requirements for new features

2011-03-10 Thread Clark J. Wang
/tct/tip) and Python has PEP (Python Enhancement Proposal: http://www.python.org/dev/peps/). -- Clark J. Wang

Re: BASH_SUBSHELL documentation misleading

2011-03-24 Thread Clark J. Wang
of the current shell in the past. That's where Sam got mixed up. Agree. It's not complicated compared to, for example, =~ usage. :) -- Clark J. Wang

Re: RFE: make [[ compatible with [ 'Option'?

2011-03-29 Thread Clark J. Wang
should be quoted.) --- If, in 30 years of unix experience, I'd ever seen multiple matches for the above pattern, I would be concerned... I often use [[ ]] like this: if [[ $filename = *.log ]]; then echo ...; fi You'll often see multiple matches for the above pattern. :) -- Clark J. Wang

Re: multi line bash commands in a Makefile

2011-04-10 Thread Clark J. Wang
var1= Why it complains about needing a unary operator? -- Clark J. Wang

Re: multi line bash commands in a Makefile

2011-04-10 Thread Clark J. Wang
On Sun, Apr 10, 2011 at 7:30 PM, ali hagigat hagigat...@gmail.com wrote: Thanks Clark for the reply. 'count' is set by shell before doing make. like root count=0 Have you exported the 'count' var before invoking make? On Sun, Apr 10, 2011 at 3:10 PM, Clark J. Wang dearv...@gmail.com

Re: path completion with cd tab - similar to tcsh

2011-04-15 Thread Clark J. Wang
on this? Can I set the mode of operation as I like where the infamous space is replaced by a slash when doing cd ... TAB? Best -- Peter Toft, PhD http://petertoft.dk That also annoys me much. Try like this: $ complete -o default -o nospace -d cd $ cd $VAR/TAB -- Clark J. Wang

Signals ignored by a shell cannot be handled by its sub-shells?

2011-07-12 Thread Clark J. Wang
For example: [bash-4.2.8] # cat a.sh trap '' TERM bash b.sh [bash-4.2.8] # cat b.sh echo Now in $0 ... trap sig_TERM TERM sig_TERM() { echo got SIGTERM, exiting ... exit } kill -TERM $$ sleep 1 echo Not killed? [bash-4.2.8] # bash a.sh Now in b.sh ... Not killed? [bash-4.2.8] # -Clark

Re: Signals ignored by a shell cannot be handled by its sub-shells?

2011-07-12 Thread Clark J. Wang
On Tue, Jul 12, 2011 at 3:34 PM, Andreas Schwab sch...@linux-m68k.orgwrote: Clark J. Wang dearv...@gmail.com writes: For example: [bash-4.2.8] # cat a.sh trap '' TERM bash b.sh [bash-4.2.8] # cat b.sh echo Now in $0 ... trap sig_TERM TERM http://pubs.opengroup.org/onlinepubs

  1   2   >