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
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