bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

setting a variable from a function called from PS1


From: E R
Subject: setting a variable from a function called from PS1
Date: Wed, 25 Aug 2010 11:20:28 -0500

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

[Prev in Thread] Current Thread [Next in Thread]