Jim Hyslop wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark D. Baushke wrote:


longest=/tmp/cvsroot/another/and/another

echo $longest | sed 's:\(.*\)/\(.*\):\1 \2:' |
  read -s longer shorter

echo "$longest, $longer, $shorter"

$longer and $shorter do not retain their values outside the read
function.

I don't know how to explain it, but perhaps the following script will help you see some of it. The strange thing for me, was that I thought the first echo in min would not have any data because I had not defined longer & shorter prior to the myfunction call.

#! /bin/bash
longest="/tmp/cvsroot/another/and/another"
myfunction()
{
 read longer shorter
}
echo $longest | sed 's:\(.*\)/\(.*\):\1 \2:' > /tmp/junkme
 myfunction < /tmp/junkme
echo "$longest, $longer, $shorter"
longer=nothing
shorter=lessthannothing
echo $longest | sed 's:\(.*\)/\(.*\):\1 \2:'|read longer shorter
echo "$longest, $longer, $shorter"
longer=nothing
shorter=lessthannothing
echo $longest | sed 's:\(.*\)/\(.*\):\1 \2:' > /tmp/junkme
 myfunction < /tmp/junkme
echo "$longest, $longer, $shorter"


Though I do not have a copy, I have however read parts of one, the Oriley (bad spelling) bash book was very good on explaining some of this.

--
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter


_______________________________________________
Bug-cvs mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/bug-cvs

Reply via email to