Re: discrepancy with variable assignments and simple commands between sh and bash

2010-08-25 Thread Chet Ramey
On 8/25/10 1:39 AM, Jan Schampera wrote: > Okay, I think I found something > > [POSIX excerpts] > - When a function is executed, it shall have the syntax-error and > variable-assignment properties described for special built-in utilities in > the enumerated list at the beginning of Special Built-

setting a variable from a function called from PS1

2010-08-25 Thread E R
I've been trying to get a function called from PS1 to set a variable, e.g.: num=1 function xyz { ((num++)) date; echo "num: $num" } PS1="\$(xyz): " In this example, the global value of num doesn't change if it is called from PS1. However num does get incremented if xyz is called directly. Is

Re: setting a variable from a function called from PS1

2010-08-25 Thread Greg Wooledge
On Wed, Aug 25, 2010 at 11:20:28AM -0500, E R wrote: > I've been trying to get a function called from PS1 to set a variable, e.g.: > > num=1 > > function xyz { > ((num++)) > date; echo "num: $num" > } > > PS1="\$(xyz): " The problem here is that the command substitution (the $(...) bit) creat

Re: setting a variable from a function called from PS1

2010-08-25 Thread Dennis Williamson
PROMPT_COMMAND doesn't create a subshell. xyz () { ((num++)); date; echo -n "num: $num"; } PROMPT_COMMAND='xyz' PS1=' ' On Wed, Aug 25, 2010 at 11:20 AM, E R wrote: > I've been trying to get a function called from PS1 to set a variable, e.g.: > > num=1 > > function xyz { >  ((num++)) >  date; ec

Re: login shell crash on Mac OS X while closing file descriptors

2010-08-25 Thread Rainer Müller
On 2010-08-24 15:59 , Chet Ramey wrote: > Well, if they cause bash to crash, I suppose removing that code (or > removing the #define) is a good place to start. > > That code has been there for a very long time. Maybe if you changed it > to turn on the FD_CLOEXEC bit instead of closing the fd we c