Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-09 Thread Stephane Chazelas
On Sun, Sep 09, 2007 at 04:58:23PM +0200, Pierre-Philippe Coupard wrote: [...] >while [ 1 ];do > echo Test1 > echo Test2 >> file.txt > sleep 1 >done > >As expected, when this script is run in the background (&), the > console >slowly fills

Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-09 Thread Stephane Chazelas
On Sun, Sep 09, 2007 at 07:36:52PM +0200, Andreas Schwab wrote: > Stephane Chazelas <[EMAIL PROTECTED]> writes: > > > Bonjour Pierre-Philippe, > > > > can be reproduced with 3.2.25 and with: > > > > bash -c 'trap "" PIPE; sleep 1; echo

Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-09 Thread Stephane Chazelas
On Sun, Sep 09, 2007 at 07:10:59PM +0100, Stephane Chazelas wrote: [...] > What OS and version of glibc? I do get the error message but I > get both a and b in the file. > > That was on Linux, glibc 2.6.1. [...] Actually, bash -c 'echo a; echo b > a' >&- i

Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-09 Thread Stephane Chazelas
On Sun, Sep 09, 2007 at 08:44:25PM +0200, Pierre-Philippe Coupard wrote: [...] > - akula, my bleeding edge box, is a Debian-unstable box upgraded yesterday > sept 8, 2007. It runs linux-2.6.17.7, libc6-2.6.1 > > - kilo, my most up-to-date box where bash still seems to behave properly > with regar

Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-09 Thread Stephane Chazelas
On Sun, Sep 09, 2007 at 10:08:14PM +0200, Andreas Schwab wrote: > Stephane Chazelas <[EMAIL PROTECTED]> writes: > > > On Sun, Sep 09, 2007 at 07:10:59PM +0100, Stephane Chazelas wrote: > > [...] > >> What OS and version of glibc? I do get the error message but I

Re: Bug#429021: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-10 Thread Stephane Chazelas
On Mon, Sep 10, 2007 at 12:05:57AM +0200, Aurelien Jarno wrote: [...] > >>> bash -c 'echo a; echo b > a' >&- > >>> > >>> is enough for me to reproduce the problem. [both "a" and "b" seen in file "a".] > >> Guess you have a buggy libc, then. > > [...] > > > > I wouldn't be surprised if it has to

Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-10 Thread Stephane Chazelas
On Mon, Sep 10, 2007 at 11:56:33AM +0400, Dmitry Potapov wrote: > On Sun, Sep 09, 2007 at 10:18:07PM +0100, Stephane Chazelas wrote: > > Now, I'm not sure if we can say that the new glibc behavior > > observed is bogus (other than it's different from the behavior > &

Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-10 Thread Stephane Chazelas
On Mon, Sep 10, 2007 at 02:17:41PM +0400, Dmitry Potapov wrote: [...] > On Mon, Sep 10, 2007 at 09:08:33AM +0100, Stephane Chazelas wrote: > > thanks for replying, I gave a list in another email. I tried on > > Solaris 7 and HPUX and both seem to flush the buffer upon an > >

Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-10 Thread Stephane Chazelas
On Mon, Sep 10, 2007 at 11:57:34AM -0400, Chet Ramey wrote: > Andreas Schwab wrote: > > Chet Ramey <[EMAIL PROTECTED]> writes: > > > >> What's needed is a portable interface like BSD's fpurge(3). > > > > This is also available from glibc as __fpurge (likewise on Solaris). > > Yes, though I have

Re: builtin echo command redirection misbehaves in detached scripts when terminal is closed

2007-09-10 Thread Stephane Chazelas
On Mon, Sep 10, 2007 at 09:25:26PM +0400, Dmitry Potapov wrote: [...] > > With dietlibc: > > > > $ ./t > > signal handler called, sig=2 > > writer: num_bytes=80008 num_lines=10001 > > writer: expected num_bytes=8 but was 80008 > > reader: num_bytes=80007 num_lines=1 > > reader: number of m

Re: bash scripting help

2007-09-12 Thread Stephane CHAZELAS
2007-09-12, 10:00(-07), chitti: > > I need to seperate the UDP and TCP ports from the /etc/services files. > any pointers or help on scripting this in bash would be helpful > thanks awk ' NF == 0 || $1 ~ /^#/ {next} $2 ~ /\/tcp$/ {print > "services.tcp"; next} $2 ~ /\/udp$/ {print > "service

Re: Missing character when using ${VAR:1} and length(VAR)==1

2007-09-20 Thread Stephane Chazelas
On Fri, Sep 21, 2007 at 05:16:03AM +0200, Jan Schampera wrote: > Chet Ramey wrote: > >>> Description: >>> there is missing a charachter when using the following: >>> # TT="oo"; echo "l${TT:1}l" >>> lol >>> # TT="o"; echo "l${TT:1}l" >>> l >> I can't reproduce

Re: using NUL in scripts

2007-09-27 Thread Stephane Chazelas
On Wed, Sep 26, 2007 at 09:04:19PM -0400, Mike Frysinger wrote: > is it even possible to utilize NUL in scripts ? or does bash just strip it > out ? for example, trying to work with binary data: > foo=$( echo "${foo}" > new-file > the "new-file" will be exactly "binary-file" if all NUL bytes are

Re: Function visibility

2007-10-02 Thread Stephane Chazelas
On Mon, Oct 01, 2007 at 04:43:15PM -0700, retiredff wrote: > > I have several functions in my /etc/profile (Mac OSX 10.4.9). I can use the > functions at the commandline, however inside of scripts I receive an error. > I'll use an example of a function I have called cecho that echo's a string > in

Re: Function visibility

2007-10-02 Thread Stephane Chazelas
On Tue, Oct 02, 2007 at 10:57:16AM -0600, Bob Proulx wrote: > Stephane Chazelas wrote: > > To work around that, you have to do things like this in > > /etc/profile: > > ... > > And do something similar in your ~/.profile for your ~/.bashrc. > > While that is norm

Re: Function visibility

2007-10-02 Thread Stephane Chazelas
On Tue, Oct 02, 2007 at 01:43:05PM -0600, Bob Proulx wrote: [...] > The AT&T ksh uses $ENV for the same purpose but does not automatically > source a kshrc file. Therefore a very common configuration for the > typical user in their profile is to set ENV=$HOME/.kshrc and use it > for all of the sam

Re: IS there a label in ksh / bash for re-startability? Can you add this functionality?

2007-10-04 Thread Stephane Chazelas
On Thu, Oct 04, 2007 at 11:33:17AM -0400, Rajeswar N wrote: >Hi PAL, > > I am faced with a problem of running a huge list of steps through ksh / > bash. > > IF for some reason task "n" fails, I am not able to re-start the script > from the nth step. > > IS there a lable available in ksh?

read -sp xx displays xx before disabling echo.

2007-10-05 Thread Stephane Chazelas
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='ba

Re: bash -n doesn't seem to catch all syntax errors...

2007-10-16 Thread Stephane Chazelas
On Mon, Oct 15, 2007 at 06:27:43PM -0400, Ken Failbus wrote: > Hi Guys, > > When I specify on command-line "bash -n ". Bash doesn't > check for valid syntax errors. E.g. if variable is missing a "$" infront > of it while assigning a value. This is not catched by bash. Is there a > more specific op

Re: error with ' in command substitution

2007-10-31 Thread Stephane Chazelas
On Tue, Oct 30, 2007 at 06:58:10PM -0600, Eric Blake wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > According to Scott Moser on 10/30/2007 7:12 AM: > > #= test.sh = > > x=$(cat <<"EOF" > > bad' syntax > > EOF > > ) > > > > > So, I'm not 100% certain what the "correct" behavi

Re: run-fg-editor for bash?

2007-11-01 Thread Stephane Chazelas
On Thu, Nov 01, 2007 at 07:48:13AM -0700, Dan Nicolaescu wrote: > > In tcsh the command run-fg-editor bound by default to C-M-z is > extremely useful when you have an editor suspended. > It makes it very easy to return to the editor, do some editing, then > suspend the editor again, and the comma

Re: truncating the path in the bash prompt?

2007-11-01 Thread Stephane Chazelas
On Thu, Nov 01, 2007 at 08:01:58AM -0700, Dan Nicolaescu wrote: > > In tcsh %c can be used to only show the last few directory names in a > path (also see the ellipsis variable). > > For example for this directory: > > /lib/modules/2.6.21-1.3194.fc7/kernel/drivers/char/hw_random/ > > the pro

Re: document export x=1 y=$x

2008-03-18 Thread Stephane Chazelas
On Tue, Mar 18, 2008 at 01:11:35AM +0800, [EMAIL PROTECTED] wrote: > On the man page at section "export", mention that the latter below > will not do what one expects, as here revealed: > $ set -x > $ a=1 b=$a > + a=1 > + b=1 > $ export x=1 y=$x > + export x=1 y= > + x=1 > + y= > Yes I'm sure it is

Re: [Pkg-shadow-devel] Bug#476519: shell-mode garbles input

2008-05-02 Thread Stephane Chazelas
On Fri, May 02, 2008 at 06:08:41AM +0800, [EMAIL PROTECTED] wrote: > As http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=476519 says, maybe > it is a bash bug: with Debian sid's BASH_VERSION=3.2.33(1)-release > about half the time the below works normally, the other half some > magic hand sends "ex

Re: [Pkg-shadow-devel] Bug#476519: shell-mode garbles input

2008-05-02 Thread Stephane Chazelas
On Fri, May 02, 2008 at 11:27:00PM +0800, [EMAIL PROTECTED] wrote: > SC> Try > SC> sudo env -i SHELLOPTS=xtrace su -p - nobody > (I don't use sudo) > uid=0(root) gid=0(root) groups=0(root) > # env -i SHELLOPTS=xtrace su -p - nobody > + PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games > + '

Re: [Pkg-shadow-devel] Bug#476519: shell-mode garbles input

2008-05-02 Thread Stephane Chazelas
On Fri, May 02, 2008 at 11:27:00PM +0800, [EMAIL PROTECTED] wrote: > SC> Try > SC> sudo env -i SHELLOPTS=xtrace su -p - nobody > (I don't use sudo) > uid=0(root) gid=0(root) groups=0(root) > # env -i SHELLOPTS=xtrace su -p - nobody > + PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games > + '

Re: [Pkg-shadow-devel] Bug#476519: shell-mode garbles input

2008-05-02 Thread Stephane Chazelas
On Sat, May 03, 2008 at 12:30:02AM +0800, [EMAIL PROTECTED] wrote: > Here we see the typical deal. You asked me about ulimit. [..] Could you try ulimit -a? Have you got a lot of processes running as "nobody"? $ ps -fjlLunobody $ sudo lsof -u nobody Or maybe it could be "su" that exits and bash

Re: [Pkg-shadow-devel] Bug#476519: shell-mode garbles input

2008-05-04 Thread Stephane Chazelas
On Sun, May 04, 2008 at 10:14:26AM +0800, [EMAIL PROTECTED] wrote: [...] > SC> Have you tried changing nobody's shell? > I don't want to. Then, can you try: su - nobody -c ksh su - nobody -c pdksh su - nobody -c zsh Also, what about: perl -e '$<=$>=$(=$)=65534; exec sh' perl -e '$<=$>=$(=$)=655

Re: at which byte do two strings differ

2008-05-06 Thread Stephane CHAZELAS
2008-05-06, 01:53(-04), Nathan Coulter: > 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'd suggest you fix the locale to being C for more portable results.

Re: function names which contain a 'dash' character

2008-05-08 Thread Stephane Chazelas
On Wed, May 07, 2008 at 05:50:59PM -0400, Chet Ramey wrote: > Poor Yorick wrote: >> ksh refuses to define functions which contain a dash ("-") in the name. >> The >> Bash manual also defines 'name' as consisting solely of letters, numbers, >> and >> underscores. So shouldn't bash refuse to crea

export -p may output invalid variables

2008-05-09 Thread Stephane Chazelas
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='ba

Re: spaces in the shebang interpreter path

2008-05-11 Thread Stephane Chazelas
On Sun, May 11, 2008 at 12:37:12PM -0600, Bob Proulx wrote: > Felix Schwarz wrote: > > I'm not able to specify an interpreter in a shebang line if the path > > to this interpreter contains spaces. > > That is correct. It is part of the implementation of the Berkeley #! > exec(2) h

Re: spaces in the shebang interpreter path

2008-05-12 Thread Stephane Chazelas
On Sun, May 11, 2008 at 02:01:29PM -0400, Paul Jarc wrote: > Felix Schwarz <[EMAIL PROTECTED]> wrote: > > I'm not able to specify an interpreter in a shebang line if the path > > to this interpreter contains spaces. > > It's actually the kernel that interprets that line, not bash.

Re: Function definition syntax inconsistencies

2008-06-05 Thread Stephane Chazelas
On Thu, Jun 05, 2008 at 06:31:36AM +0200, Jan Schampera wrote: [...] > The function definition is allowed in 3 forms: > 1. NAME() ... That's the Bourne and POSIX syntax > 3. function NAME ... That's the ksh syntax. It's probably only there for compatibility with ksh (note

Re: Function definition syntax inconsistencies

2008-06-05 Thread Stephane Chazelas
On Thu, Jun 05, 2008 at 10:07:51AM +0200, Andreas Schwab wrote: > Stephane Chazelas <[EMAIL PROTECTED]> writes: > > > I suspect this: > > $ sh -c 'function() { echo a; }; function' > > sh: -c: line 0: syntax error near unexpected token `(' > >

[doc] read -t and sockets, devices...

2008-06-05 Thread Stephane Chazelas
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='ba

$IFS and "[EMAIL PROTECTED]:offset}"

2008-06-05 Thread Stephane Chazelas
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='ba

Re: $IFS and "[EMAIL PROTECTED]:offset}"

2008-06-06 Thread Stephane Chazelas
On Fri, Jun 06, 2008 at 10:38:41AM +0200, Andreas Schwab wrote: > Stephane Chazelas <[EMAIL PROTECTED]> writes: > > > The behavior is the same in ksh, but in ksh ${@:0:1} expands to > > $0 which makes it more understandable ($0 has its meaning in > > functions

Re: $IFS and "[EMAIL PROTECTED]:offset}"

2008-06-06 Thread Stephane Chazelas
On Thu, Jun 05, 2008 at 05:39:58PM +0100, Stephane Chazelas wrote: [...] > $ bash -c 'printf "%s\n" "${@:2}"' x 1 2 "3 4" 5 > 2 > 3 4 > 5 > $ bash -c 'IFS=a; printf "%s\n" "${@:2}"' 0 1 2 "3 4" 5 > 2

Re: $IFS and "[EMAIL PROTECTED]:offset}"

2008-06-06 Thread Stephane Chazelas
On Fri, Jun 06, 2008 at 11:08:23AM +0200, Andreas Schwab wrote: > Stephane Chazelas <[EMAIL PROTECTED]> writes: > > > It still doesn't explain why ${@:1:1} expands to $1 and not $2 > > For positional parameters indexing starts at 1. [...] Alright sorry, that was

read -d on a terminal

2008-06-06 Thread Stephane Chazelas
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='ba

Re: [POSIX conformance] "." looks for file in the current directory

2008-06-10 Thread Stephane Chazelas
On Tue, Jun 10, 2008 at 11:20:54AM +0200, Andreas Schwab wrote: > [EMAIL PROTECTED] writes: > > > SUSv3> Some older implementations searched the current directory > > SUSv3> for the file, even if the value of PATH disallowed it. This > > SUSv3> behavior was omitted from this volume of IEEE Std > >

Re: [POSIX conformance] "." looks for file in the current directory

2008-06-10 Thread Stephane Chazelas
On Tue, Jun 10, 2008 at 06:21:13AM -0600, Eric Blake wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > According to Andreas Schwab on 6/10/2008 3:20 AM: > | [EMAIL PROTECTED] writes: > | > |> SUSv3> Some older implementations searched the current directory > |> SUSv3> for the file, even

Re: [POSIX conformance] "." looks for file in the current directory

2008-06-10 Thread Stephane Chazelas
On Tue, Jun 10, 2008 at 11:19:47AM -0400, Chet Ramey wrote: [...] >> So it is indeed a bug. > > Yes, it is. I fixed it the last time this came up, in January. [...] Thanks, It still seems to be there in 3.2.39 which seems to be the latest version or ftp.gnu.org. If there's a newer version, wher

Re: Waiting for outpu

2008-06-11 Thread Stephane Chazelas
On Tue, Jun 10, 2008 at 06:11:26PM -0700, stoyboy wrote: > > I am trying to create a script that will run continuously until the out of a > command reaches a specific point. > I have a command called showOutput and all it does it output the progress of > running job, i want to create a script or a

Re: [doc] read -t and sockets, devices...

2008-06-13 Thread Stephane Chazelas
On Fri, Jun 13, 2008 at 06:52:48PM -0400, Chet Ramey wrote: [...] >> Also, it may be good to specify that, if the timeout is >> reached, bash will consume the input but will not put >> that consumed input into the variable: > > Actually, the bash-4.0 implementation will put the input

Re: [doc] read -t and sockets, devices...

2008-06-15 Thread Stephane Chazelas
On Sat, Jun 14, 2008 at 10:15:06PM -0400, Chet Ramey wrote: > Stephane Chazelas wrote: > >> What about a different $? (like 2 for timeout)? > > That's reasonable. I'm thinking 128+SIGALRM. [...] That makes sense, but it's a bit of a pain to handle. read -t 10

Re: Unable to do a for loop in "here document"

2008-07-09 Thread Stephane Chazelas
On Tue, Jul 08, 2008 at 08:44:47PM -0700, Mr Aras wrote: [...] > #!/bin/sh > sh <<-EOF > for word in hello world > do > echo word = $word > done > EOF > > output is: > word = > word = > > > Can someone tell me why this doesn't work? I've been going nuts trying to > figure this one out. [

Re: removing null elements from an array

2008-07-18 Thread Stephane Chazelas
On Thu, Jul 17, 2008 at 11:12:47PM +, Poor Yorick wrote: > To get rid of null elements in an array, I currently do something like this: > > bash-3.2$ var1=("with spaces" "more spaces" '' "the end") > bash-3.2$ for v in "[EMAIL PROTECTED]"; do if test "$v"; then > var2+=("$v"); fi; do

Re: removing null elements from an array

2008-07-18 Thread Stephane Chazelas
On Fri, Jul 18, 2008 at 08:52:47AM -0400, Poor Yorick wrote: > Stephane Chazelas wrote: >> >> In zsh, removing the empty elements is just a matter of >> >> var1=($var1) > > Wouldn't this corrupt the elements with spaces, just as in bash? [...] No, zsh d

Re: Variable scoping

2008-07-27 Thread Stephane Chazelas
On Fri, Jul 25, 2008 at 08:58:21AM +0300, Pierre Gaston wrote: [...] > With "sh" (a posix shell) no > In bash you can use the builtin "local" (or declare). [...] See http://stchaz.free.fr/locvar.sh for one way to implement local scope in a POSIX script. (those functions have not been thoroughly

Re: =~ behaves differently in bash 3.2 and 3.0

2008-10-24 Thread Stephane CHAZELAS
2008-10-24, 14:56(+08), 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 patter

Re: lost output from asynchronous lists

2008-10-28 Thread Stephane Chazelas
On Mon, Oct 27, 2008 at 11:12:24PM +0100, Ralf Wildenhues wrote: [...] > --- foo.sh --- > #! /bin/sh > > do_work () > { > sleep 1 > echo "work $i is done" > } > > for i in 1 2 3 4 5 6 7 8 9 10 > do > ( > do_work $i > ) & > done > wait > > --- bar.sh --- > #! /bin/sh > > ./foo.sh > s

Re: lost output from asynchronous lists

2008-10-29 Thread Stephane Chazelas
On Tue, Oct 28, 2008 at 10:51:13PM +0100, Ralf Wildenhues wrote: [...] > > : > stdout > stderr [...] > Yes. For shell portability, I'll write the first line as > : > stdout > : > stderr > > though. Why? I can't see why ": > stdout > stderr" wouldn't work in any shell. It should even work in

Re: lost output from asynchronous lists

2008-11-02 Thread Stephane Chazelas
On Sat, Nov 01, 2008 at 11:21:01PM -, Sven Mascheck wrote: [...] > : > stdout > stderr [...] > > It fails on old Ultrix sh, which can't redirect the same fd more than once > > in a single statement. But that platform is relatively dead these days. > > More detailed: > > - It actually w

Re: Problems applying patches

2008-11-18 Thread Stephane Chazelas
On Tue, Nov 18, 2008 at 07:09:19PM +, Dan wrote: [...] > Questions: > 1) Does my guide (see below) for applying the patches make sense? I > couldn't see any other way to make this work without creating the symbolic > links and using the -p0 option as recommended by Chet. The steps in the > g

Re: document -u $@ $* special case

2008-11-26 Thread Stephane Chazelas
On Wed, Nov 26, 2008 at 01:25:17PM -0500, Chet Ramey wrote: > [EMAIL PROTECTED] wrote: > > Gentlemen, I have discovered a documentation oversight. In the manual, > > we see: > > set -u -- > > : $@ $* > > : $1 > > > > and > > > > set -- > > : ${*?} [EMAIL PROTECTED] > > : ${1?} > > > > Therefore

Re: command not found magic

2008-12-04 Thread Stephane Chazelas
On Thu, Dec 04, 2008 at 10:16:20AM +0100, Roman Rakus wrote: > probably you heard about this topic. It is invoked by ubuntu guys. See > https://launchpad.net/ubuntu/+spec/command-not-found-magic > I would like to know, what do you think about it. It needs a small change > in bash. [...] A note a

Re: passing array to command line argument.

2008-12-09 Thread Stephane Chazelas
On Tue, Dec 09, 2008 at 09:14:51AM -0500, Chet Ramey wrote: > > > > Hello i would like to pass an array to my script command line argument, but > > only the first element of the array is displayed. Here is my process : > > > > script1: > > my_array=(el1 el2 el3) > > script2 -f $my_array > > You

Re: command substitution and word splitting

2008-12-13 Thread Stephane Chazelas
On Sat, Dec 13, 2008 at 09:30:27AM +0100, Andreas Schwab wrote: > "S. Sevki Dincer" writes: > > > i want to start building a project with ./configure --prefix=... $(myflags) > > where myflags is an executable text file on my path. myflags has the > > following in it: > > printf 'CFLAGS="-O2 -fomi

Re: globstar syntax

2009-01-21 Thread Stephane CHAZELAS
2009-01-21, 02:48(+01), Sebastian Kapfer: > Am Montag, den 19.01.2009, 10:14 -0800 schrieb Alex Reed: >> Should the globstar (**) syntax allow for partial parameter matching >> (i.e. **.c to find all *.c files in the current directory and its sub- >> directories)? >> >> Currently this can be imple

Re: globstar syntax

2009-01-22 Thread Stephane CHAZELAS
2009-01-21, 22:49(-05), Chet Ramey: > Stephane CHAZELAS wrote: > >> Apparently, just like ksh93, bash4 only implements ** and not *** >> nor the globbing qualifiers, but like zsh it requires **/*.c >> (**.c won't work). > > I'm not sure what version of ks

Re: The colon

2009-01-26 Thread Stephane Chazelas
On Mon, Jan 26, 2009 at 07:13:32AM +0100, Jan Schampera wrote: > Hi. > > In comp.unix.shell [1] somebody wondered about > IFS=: read a b <<< a:b; echo "'$a' '$b'" > ending up in > 'a b' '' > > Korn and Z seem to behave different. I see that across all my available > Bash versions. I remember

Re: Migrating from tcsh to bash (issues)

2009-02-03 Thread Stephane CHAZELAS
2009-02-3, 19:38(+00), Simos: [...] > I have been using tcsh for a long time and I plan to move to bash. [...] I'd recommend moving to zsh instead. The transition is easier from tcsh and this way to won't have to move from bash to zsh later on. -- Stéphane

Re: Migrating from tcsh to bash (issues)

2009-02-04 Thread Stephane CHAZELAS
2009-02-3, 22:07(+00), Simos: > On Tue, Feb 3, 2009 at 9:24 PM, Stephane CHAZELAS > wrote: >> 2009-02-3, 19:38(+00), Simos: >> [...] >>> I have been using tcsh for a long time and I plan to move to bash. >> [...] >> >> I'd recommend moving to zsh

Re: mapfile usage

2009-02-04 Thread Stephane CHAZELAS
2009-02-4, 10:50(-08), Alex Reed: > Can someone please explain how 'mapfile' should be used? I am trying: > > cat file.txt | mapfile > for i in ${MAPFILE};do echo $i; done > > and I see no output. mapfile would be run in a subshell. Try mapfile < file.txt Note that the for loop syntax above is

Re: mapfile usage

2009-02-22 Thread Stephane CHAZELAS
2009-02-4, 19:59(+00), Stephane CHAZELAS: [...] > Also, it looks like it should guard against > seq 5 | mapfile -C echo -c0 > > That command above cannot be interrupted with [...] Note that that minor bug is still in 4.0-release. I still don't get the rationale behind that b

Re: file descriptors, redirection and other animals....

2009-03-09 Thread Stephane CHAZELAS
2009-03-9, 05:03(-07), simonm: > Hi all, > > Here's a quick one... > > The following works as expected: > > # exec 9<>test.file ; jot 50 >&9 ; tail -5 <&9 9>&- > 46 > 47 > 48 > 49 > 50 That must be a bug in your tail implementation. That output should only happen if test.file already contains tho

Re: file descriptors, redirection and other animals....

2009-03-10 Thread Stephane CHAZELAS
2009-03-10, 01:54(-07), simonm: [...] > cat very_large_text_file | a | long | and | complex | chain | of | > pipes | tee <(command_one) <(command_two) 1>/dev/null > > So, I want to apply command_one and command_two to the whole output of > the resulting text stream coming from "pipes". > > Is there

Re: bash: command_substitute: cannot duplicate pipe as fd 1: Bad file descriptor

2009-03-15 Thread Stephane CHAZELAS
2009-03-12, 06:47(-07), ipif: [...] > sh-3.2# bash > bash: command_substitute: cannot duplicate pipe as fd 1: Bad file descriptor > > (currently I'm using bash as init) [...] > In my opinion this problem might not be bash related, but I have no idea > what goes wrong. Unfortunately gdb seems to rel

Re: IFS valid characters

2009-03-15 Thread Stephane CHAZELAS
2009-03-10, 15:43(-04), Chet Ramey: >> What are the valid charactes for the IFS variable? In particular, is '\0' a >> valid one? > > Technically, yes, but in practice it's not useful. There are too many things > represented as C strings to make NUL work right. [...] And to answer the rest of th

Re: IFS valid characters

2009-03-17 Thread Stephane CHAZELAS
2009-03-16, 09:53(+01), Dave B: > Stephane CHAZELAS wrote: > >> 2009-03-10, 15:43(-04), Chet Ramey: >>>> What are the valid charactes for the IFS variable? In particular, is '\0' >>>> a >>>> valid one? >>> Technically, ye

Re: using mapfile is extreamly slow compared to oldfashinod ways to read files

2009-03-27 Thread Stephane CHAZELAS
2009-03-26, 21:22(-04), Chet Ramey: > Chris F.A. Johnson wrote: > >>Chet, how about an option to mapfile that strips leading and/or >>trailing spaces? >> >>Another useful option would be to remove newlines. > > I'm disinclined to add one, since it's easy enough to use the > ${line##[

Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Stephane CHAZELAS
2009-04-2, 12:33(-04), Chris F.A. Johnson: > On Thu, 2 Apr 2009, Mike Coleman wrote: > >> [Oops--I sent that incomplete.] >> >> It would be nice if there was some really brief syntax for >> >>$(type -p somecommand) >> >> I find myself using this all day long with 'ls', 'file', 'ldd', >> 'string

Re: str1 < str2 does not respect locale

2009-04-08 Thread Stephane CHAZELAS
2009-04-8, 08:35(-04), Chet Ramey: >> Configuration Information [Automatically generated, do not change]: >> Machine: hppa2.0 >> OS: hpux10.20 >> Compiler: /net/appl/gcc-3.3/bin/gcc >> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='hppa2.0' >> -DCONF_OSTYPE='hpux10.20' -DCONF_MACHTYPE='hpp

Re: how to pass arguments with space inside?

2009-04-10 Thread Stephane CHAZELAS
2009-04-09, 23:18(+02), Mart Frauenlob: [...] > I wonder where's the bug report? > You seem to miss that the support place for bash is 'gnu.bash' not > 'gnu.bash.bug'. [...] Interesting, I can see that Google groups has a gnu.bash newsgroup with messages that date back as far as 1999 newsgroup. I

Re: bash 4.x filters out environmental variables containing a dot in the name

2009-06-27 Thread Stephane CHAZELAS
2009-06-26, 13:58(+02), Christian Krause: > Hi Chet, > > Thanks for the answers. The problem is now, that this behavior of the > bash creates some real problems outside, probably with a larger impact. > Before asking the kernel developers to change parts of linux kernel's > build system, I'd like t

Re: Is comma a metacharacter?

2009-06-28 Thread Stephane CHAZELAS
2009-06-28, 00:02(-07), Steve Ward: > The comma character (',') is in function sh_backslash_quote but not in > function sh_contains_shell_metas. > > Is comma a metacharacter? [...] Only is some special constructions: $ echo {a} {a} $ echo {a,b} a b $ echo {a\,b} {a,b} -- Stéphane

Re: bgnice?

2009-06-28 Thread Stephane CHAZELAS
2009-06-28, 15:40(-04), Chet Ramey: > Linda Walsh wrote: >> I thought I remembered a 'bgnice' value under the 'set' or shopt >> options It doesn't seem to be in my current bash. Was that >> only a ksh-ism? > > It's only in ksh. I don't think it's that great an idea. It's not > on the list o

Re: bash 4.x filters out environmental variables containing a dot in the name

2009-06-30 Thread Stephane CHAZELAS
2009-06-29, 10:03(-04), Chet Ramey: > >> and it's a bug that bash-4 is filtering them. > > Maybe, maybe not. That's open to interpretation. Here's how I see it. > >> not allowing them to be used in >> the shell is fine (echo ${vmlinux.lds}), but removing them from the >> environment and thus no

Re: echo "-e" produces no outputs

2009-07-17 Thread Stephane CHAZELAS
2009-07-17, 13:09(-06), Eric Blake: > > According to Huang Tao on 7/17/2009 9:46 AM: >> I'm not sure whether it is a bug >> how can i echo the text string "-e" barely ( or "-n", "-E") >> i tried >> $echo "-e" >> $echo '-e' >> and some other inputs, all of which produced no outputs. > > Instead of u

Re: printf -v doesn't allow array assignment

2009-07-18 Thread Stephane CHAZELAS
2009-07-17, 22:02(-04), Chris F.A. Johnson: > > $ printf -v q[2] "%s" "$RANDOM" > bash: printf: `q[2]': not a valid identifier > > > I know I can work around it with a temporary variable, but it > would be nice if it could be done in a single step. [...] Just do a "touch q2" before and t

Re: echo "-e" produces no outputs

2009-07-20 Thread Stephane CHAZELAS
2009-07-19 21:07:20 -0400, Chet Ramey: [...] > > Note that it's a known non POSIX-conformance of bash. > > > > POSIX is explicit that > > > > echo -e > > > > Should output "-e\n". > > That's why bash has the `xpg_echo' option. You can build bash in such > a way that it's always enabled. [...]

Re: slight OT: shell-script programing style -- origins and change?

2009-10-25 Thread Stephane CHAZELAS
2009-10-25, 12:05(-07), Linda Walsh: > This is not exactly bash specific, but I was looking at a shell script > recently and they use the age old convention of using upper case > names for all their shell variables. [...] By convention, _environment_ variables are upper-case, which helps in a sh

[OT] Re: how to start in "overwrite-mode"

2009-10-28 Thread Stephane CHAZELAS
2009-10-27, 16:29(-04), Jim Lawson: [...] > I have a user we're trying to encourage to migrate from tcsh to bash, > who is used to his shell starting up in overwrite mode (as opposed to > the default Insert mode.) > > Long story short, while I can easily bind a key to the "overwrite-mode" > readlin

Re: [OT] Re: how to start in "overwrite-mode"

2009-10-28 Thread Stephane CHAZELAS
2009-10-28 09:00:59 -0400, Chet Ramey: > > zle-line-init() zle overwrite-mode > > zle -N zle-line-init > > > > To get back on topic, bash is the only Bourne-like shell that I > > know that doesn't allow that function definition syntax above, > > I've always wondered why. > > The Posix grammar has

Re: [OT] Re: how to start in "overwrite-mode"

2009-10-28 Thread Stephane CHAZELAS
2009-10-28 09:46:49 -0400, Chet Ramey: [...] > >> The Posix grammar has never allowed it (a `function_body' must be a > >> compound command, and that's what bash implements), and there has > >> never been sufficient demand to add it as an extension. > > [...] > > > > It's never allowed it to POSI

Re: [OT] Re: how to start in "overwrite-mode"

2009-10-28 Thread Stephane CHAZELAS
2009-10-28 11:06:09 -0400, Chris F.A. Johnson: > On Wed, 28 Oct 2009, Greg Wooledge wrote: > > > On Wed, Oct 28, 2009 at 02:00:53PM +0000, Stephane CHAZELAS wrote: > > > I can understand it. I was more curious about the origins. After > > > all, that breaks Bourn

Re: how to start in "overwrite-mode"

2009-10-29 Thread Stephane CHAZELAS
2009-10-28, 20:28(-04), Dave Rutherford: [...] > Add to .Xdefaults: XTerm*answerbackString: ^[[2~ > Add to .bashrc (and .profile if it doesn't source .bashrc): > bind '"^[[2~": overwrite-mode' > PROMPT_COMMAND='echo -n ^E' [...] Along those lines, you could use the TIOCSTI ioctl. That woul

Re: how to start in "overwrite-mode"

2009-10-29 Thread Stephane CHAZELAS
2009-10-29, 07:23(+00), Stephane CHAZELAS: > 2009-10-28, 20:28(-04), Dave Rutherford: > [...] >> Add to .Xdefaults: XTerm*answerbackString: ^[[2~ >> Add to .bashrc (and .profile if it doesn't source .bashrc): >> bind '"^[[2~": overw

Re: bash is not capable of comparing of strings and real numbers

2009-12-11 Thread Stephane Chazelas
2009-12-07, 22:22(+00), pk: > phani krishna jampala wrote: > >> bash is not capable of comparing of strings ( imean interms of lessthan or >> greater than etc) > > It is, if you use [[ ]] > > a="abcd" > b="bcde" > if [[ "$b" > "$a" ]]; then > echo "$b is greater than $a" > fi [...] Or the "["

Re: best way to test for empty dir?

2009-12-12 Thread Stephane CHAZELAS
2009-12-11, 16:16(+00), Marc Herbert: > Sven Mascheck a écrit : >> Chris F.A. Johnson wrote: >> >>> This has been discussed more than once in c.u.s; check the >>> archives. >> >> and that's why we better discuss it here now? > > I think Chris' message was more like: "let's not discuss it at all a

Re: best way to test for empty dir?

2009-12-12 Thread Stephane CHAZELAS
2009-12-12, 10:21(+00), Stephane CHAZELAS: [...] >> exists() >> { >> [ -e "$1" -o -L "$1" ] >> } > > $ exists = > bash: [: too many arguments > > [ -e "$1" ] -o [ -L "$1" ] [...] Sorry, I meant [ -e "$1" ] || [ -L "$1" ] -- Stéphane

Re: add a way to declare global variables

2009-12-12 Thread Stephane CHAZELAS
2009-12-12, 11:28(+01), Bernd Eggink: > Am 10.12.2009 10:40, schrieb konsolebox: > >> I hope the development team will also consider adding a way in bash to >> declare global variables inside a function perhaps either with an >> option in typeset or declare like -g (same as zsh) and/or a builtin >>

Re: kill builtin incorrectly works with -s -n and -PGID options

2009-12-12 Thread Stephane CHAZELAS
2009-12-11, 06:17(-07), Eric Blake: > > According to Roman Rakus on 12/11/2009 6:08 AM: >> kill builtin incorrectly thinks that -PGID is signal name even if the >> signal name is set by -s or -n option. >> >> [rra...@dhcp-lab-170 ~]$ kill -s TERM -5032 >> bash: kill: 5032: invalid signal specifica

Re: add a way to declare global variables

2009-12-12 Thread Stephane CHAZELAS
2009-12-12, 12:37(-05), Chet Ramey: > On 12/12/09 5:24 AM, Bernd Eggink wrote: > >> It's the other way round. Regarding typeset and declare, the man page >> says: " When used in a function, makes each name local, as with the >> local command. " So within a function, typeset, declare, and local are

Re: $(pwd) != $(/bin/pwd)

2010-01-05 Thread Stephane CHAZELAS
2010-01-03, 17:23(-05), Chet Ramey: [...] >> da...@thinkpad ~ $ cd foo [...] >> da...@thinkpad ~/foo $ mv ~/foo ~/bar [...] >> da...@thinkpad ~/foo $ echo $PWD >> /home/darkk/foo >> da...@thinkpad ~/foo $ pwd >> /home/darkk/foo >> da...@thinkpad ~/foo $ /bin/pwd >> /home/darkk/bar [...] > It's not

Re: $(pwd) != $(/bin/pwd)

2010-01-05 Thread Stephane CHAZELAS
2010-01-05 20:23:39 +0100, Andreas Schwab: > Greg Wooledge writes: > > > On Mon, Jan 04, 2010 at 01:25:50PM +0000, Stephane CHAZELAS wrote: > >> >> da...@thinkpad ~/foo $ echo $PWD > >> >> /home/darkk/foo > > > >> Well, if I read >

Re: $(pwd) != $(/bin/pwd)

2010-01-06 Thread Stephane CHAZELAS
2010-01-05 16:40:50 -0500, Chet Ramey: > > Well, if I read > > http://www.opengroup.org/onlinepubs/9699919799/utilities/pwd.html > > correctly, bash pwd should output /home/darkk/bar in that case > > as $PWD does *not* contain an absolute path to the current > > directory. > > Bash notices this wh

Re: Problems when RANDOM without $ is used as an array index

2010-01-11 Thread Stephane CHAZELAS
2010-01-9, 06:23(-06), den...@netstrata.com: [...] > This produces the correct distribution of dice values for two six-sided dice: > > $ unset dice; for i in {1..1}; do ((dice[$RANDOM%6+1 + $RANDOM%6+1]++)); > done; echo "${di...@]}" > 290 582 837 1130 1375 1635 1315 1126 845 574 291 > > The

<    1   2   3   4   5   >