<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I'm not sure what other implications this might have, but does
      something like this work for you? You would need to apply the
      following patch[1].</p>
    <p>Manually trying to save the last context/exten/etc. in the
      dialplan itself is guaranteed to be an ugly solution. Let Asterisk
      do it for you.<br>
    </p>
    <p>[f1]<br>
      exten => s,1,NoOp(${CONTEXT})<br>
              same => n,NoOp(${CONTEXT} / ${LASTCONTEXT})<br>
              same => n,Goto(f2,s,1)<br>
      [f2]<br>
      exten => s,1,NoOp(${CONTEXT} / ${LASTCONTEXT})<br>
              same => n,NoOp(${CONTEXT} / ${LASTCONTEXT})<br>
              same => n,Hangup()<br>
    </p>
    <p>pbxdev*CLI> channel originate Local/s@f1 application Wait 30<br>
      [Jan  6 08:19:30]     -- Called s@f1<br>
      [Jan  6 08:19:30]     -- Executing [s@f1:1]
      NoOp("Local/s@f1-00000002;2", "f1") in new stack<br>
      [Jan  6 08:19:30]     -- Executing [s@f1:2]
      NoOp("Local/s@f1-00000002;2", "f1 / ") in new stack<br>
      [Jan  6 08:19:30]     -- Executing [s@f1:3]
      Goto("Local/s@f1-00000002;2", "f2,s,1") in new stack<br>
      [Jan  6 08:19:30]     -- Goto (f2,s,1)<br>
      [Jan  6 08:19:30]     -- Executing [s@f2:1]
      NoOp("Local/s@f1-00000002;2", "f2 / f1") in new stack<br>
      [Jan  6 08:19:30]     -- Executing [s@f2:2]
      NoOp("Local/s@f1-00000002;2", "f2 / f1") in new stack<br>
      [Jan  6 08:19:30]     -- Executing [s@f2:3]
      Hangup("Local/s@f1-00000002;2", "") in new stack<br>
      [Jan  6 08:19:30]   == Spawn extension (f2, s, 3) exited non-zero
      on 'Local/s@f1-00000002;2'<br>
    </p>
    <p>[1] <a class="moz-txt-link-freetext" href="https://code.phreaknet.org/asterisk/lastcontext.diff">https://code.phreaknet.org/asterisk/lastcontext.diff</a><br>
    </p>
    <div class="moz-cite-prefix">On 1/5/2022 10:22 PM, Dovid Bender
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAM3TTh09BaZu2VE2xwGxGGw4eHBitZ_rNiWnTRVk4USh5+oArw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Steve,
        <div><br>
        </div>
        <div>I thought of this but that would mean I would need to add
          this to the beginning of every context which I can do, but I
          was trying to avoid.</div>
        <div><br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Jan 5, 2022 at 10:06
          PM Steve Edwards <<a
            href="mailto:asterisk.org@sedwards.com"
            moz-do-not-send="true" class="moz-txt-link-freetext">asterisk.org@sedwards.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On
          Wed, 5 Jan 2022, Steve Edwards wrote:<br>
          <br>
          >       same = n,                     
           set(LAST-CONTEXT=${context}<br>
          <br>
          Double damn. I munged the case on ${CONTEXT}. I give up for
          today :)<br>
          <br>
          -- <br>
          Thanks in advance,<br>
-------------------------------------------------------------------------<br>
          Steve Edwards       <a href="mailto:sedwards@sedwards.com"
            target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">sedwards@sedwards.com</a>     
          Voice: +1-760-468-3867 PST<br>
                       <a
            href="https://www.linkedin.com/in/steve-edwards-4244281"
            rel="noreferrer" target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">https://www.linkedin.com/in/steve-edwards-4244281</a><br>
          <br>
          -- <br>
_____________________________________________________________________<br>
          -- Bandwidth and Colocation Provided by <a
            href="http://www.api-digital.com" rel="noreferrer"
            target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">http://www.api-digital.com</a>
          --<br>
          <br>
          Check out the new Asterisk community forum at: <a
            href="https://community.asterisk.org/" rel="noreferrer"
            target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">https://community.asterisk.org/</a><br>
          <br>
          New to Asterisk? Start here:<br>
                <a
            href="https://wiki.asterisk.org/wiki/display/AST/Getting+Started"
            rel="noreferrer" target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">https://wiki.asterisk.org/wiki/display/AST/Getting+Started</a><br>
          <br>
          asterisk-users mailing list<br>
          To UNSUBSCRIBE or update options visit:<br>
             <a
            href="http://lists.digium.com/mailman/listinfo/asterisk-users"
            rel="noreferrer" target="_blank" moz-do-not-send="true"
            class="moz-txt-link-freetext">http://lists.digium.com/mailman/listinfo/asterisk-users</a></blockquote>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
    </blockquote>
  </body>
</html>