* [gentoo-user] OT expect script question @ 2018-12-05 0:28 Adam Carter 2018-12-05 7:40 ` Gerrit Kühn 0 siblings, 1 reply; 3+ messages in thread From: Adam Carter @ 2018-12-05 0:28 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 514 bytes --] In my response matching I would like to have a catch all so if nothing specific is matched I can take an action, but when I include the "*" option, it is selected even if string1 matches. From the expect man page "In the event that multiple patterns match, the one appearing first is used to select a body." So why are actions3 getting executed when string1 is matched? If i remove the "*" section, string1 is matched. expect { "string1" { <actions1> } "string2" { <actions2> } "*" { <actions3> } } [-- Attachment #2: Type: text/html, Size: 743 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-user] OT expect script question 2018-12-05 0:28 [gentoo-user] OT expect script question Adam Carter @ 2018-12-05 7:40 ` Gerrit Kühn 2018-12-06 2:31 ` Adam Carter 0 siblings, 1 reply; 3+ messages in thread From: Gerrit Kühn @ 2018-12-05 7:40 UTC (permalink / raw To: gentoo-user On Wed, 5 Dec 2018 11:28:55 +1100 Adam Carter <adamcarter3@gmail.com> wrote about [gentoo-user] OT expect script question: > expect { > "string1" { <actions1> } > "string2" { <actions2> } > "*" { <actions3> } > } From <https://www.oreilly.com/library/view/exploring-expect/9781565920903/ch04.html> --- expect * Here the * matches anything. This is like saying, ?I don?t care what?s in the input. Throw it away.? This pattern always matches, even if nothing is there. Remember that * matches anything, and the empty string is anything! As a corollary of this behavior, this command always returns immediately. It never waits for new data to arrive. It does not have to since it matches everything. --- Could it be that it just matches empty without waiting for anything? cu Gerrit ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-user] OT expect script question 2018-12-05 7:40 ` Gerrit Kühn @ 2018-12-06 2:31 ` Adam Carter 0 siblings, 0 replies; 3+ messages in thread From: Adam Carter @ 2018-12-06 2:31 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 298 bytes --] > > Could it be that it just matches empty without waiting for anything? > Perhaps, but that would only matter if it is processing per character, not per line. I had assumed that it would not evaluate the blocks until it received an End of Line character, but I will test that assumption. Thanks [-- Attachment #2: Type: text/html, Size: 495 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-06 2:32 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-12-05 0:28 [gentoo-user] OT expect script question Adam Carter 2018-12-05 7:40 ` Gerrit Kühn 2018-12-06 2:31 ` Adam Carter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox