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 <pc88m...@gmail.com> 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): "
>
> 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 there a way I can have a function called from PS1 change the value
> of a global variable?
>
>

Reply via email to