From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13831 invoked by alias); 9 Feb 2015 11:42:07 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34479 Received: (qmail 2238 invoked from network); 9 Feb 2015 11:42:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 Message-ID: <54D89D8F.8090706@askmicah.net> Date: Mon, 09 Feb 2015 03:44:15 -0800 From: Micah Waddoups User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: zsh-workers@zsh.org Subject: Re: BUG: $_ empty on null function call References: <54D89C52.6050702@askmicah.net> In-Reply-To: <54D89C52.6050702@askmicah.net> Content-Type: multipart/mixed; boundary="------------070101020004070500030708" X-Provags-ID: V02:K0:RdM6OzMIjAIjz4q7U2ZEOmAPd1VvwqbchsLWVZwmC1r tg0l1CIXvVw2B0ODnxA2J37jQvCh2t7WvQjjbhk9L+ySeMjrPb p9/g3iBTCXOf+Ikxg+xMVV8+zLrKAnt7jPVWKTjQ/m5uqcv3Hr MAhbPhVJpwt7ooOq2vKjMPiZnCfy7BNN6ihlQiPJfWgTVaZl35 fsPrGMWaTq7rZV/NrtUi44U2EIcs/4s/t84GubZD/hBV7z77vc fTSPdS4RGLYlbtyPhNqza6Dsk+0U59Se+S+zUaZv9vKTQyv/sH V+S0HHhtxgDh18xXewQRG/os/Pi7KPUXDx13BA70wtndPbCBVX D7IZUdaWcVjjdcZBG7XGpIKC/EQoaaLplocoKLFsP X-UI-Out-Filterresults: notjunk:1; --------------070101020004070500030708 Content-Type: multipart/alternative; boundary="------------050902090606070803020704" --------------050902090606070803020704 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Again, please show mercy on me in my innexperience. The current patch-level of the ZSH shell I am using is: zsh-5.0.7-0-g208bded It is the standard "Arch Linux" zsh package as of January 2015. On 02/09/2015 03:38 AM, Micah Waddoups wrote: > Hello all, > I am still a beginner in developing, or I would tackle this issue > directly myself. The misbehavior is when the command list has a null > function with parameters, the last-command-last-parameter ($_) > built-in variable goes blank. Example: > > |local a=1 b=2 c=3; : One; function { : Two; echo $_; print -l $argv; > } $_ Three; print -l $_ Four; > ## Should print: > # Two > # One > # Three > # Three > # Four > > ## Currently prints: > # Two > # Three > # Four > > ## Conversely, when no arguments are given to the null function, > ## it operates mostly normally, but as if the function were not there:| > ||local a=1 b=2 c=3; : One; function { : Two; echo $_; print -l $argv; > }; print -l $_ Four;| > ## Outputs: > # Two > # > # One > # Four > ## ( second line is 'print -l' but $argv is empty > | > > It would seem this unexpected behavior may be the result of an > unfinished shell source where the best shell behavior was not clear to > the programmer. I admit dealing with null functions is a minor point > of dilema with script writing, but I have gotten super intricate with > the beautiful script design and features made available to me by ZSH, > and I have found that the behavior suggested at "Should print" above > is the only way that is consistent in a large script where an alias > may use a null function for better handling of parameters without > interfering with any currently same-name functions, or when a Heredoc > is used and one wants to grab the last argument to use as the > parameter of an immediately following null function. > > -- > Micah micah@askmicah.net > AskMicah.Net , Problem Solving Agency -- Micah micah@askmicah.net AskMicah.Net , Problem Solving Agency --------------050902090606070803020704 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Again, please show mercy on me in my innexperience.  The current patch-level of the ZSH shell I am using is:
   zsh-5.0.7-0-g208bded
It is the standard "Arch Linux" zsh package as of January 2015.


On 02/09/2015 03:38 AM, Micah Waddoups wrote:
Hello all,
  I am still a beginner in developing, or I would tackle this issue directly myself.  The misbehavior is when the command list has a null function with parameters, the last-command-last-parameter ($_) built-in variable goes blank.  Example:

local a=1 b=2 c=3; : One; function { : Two; echo $_; print -l $argv; } $_ Three; print -l $_ Four;
## Should print:
#  Two
#  One
#  Three
#  Three
#  Four

## Currently prints:
#  Two
#  Three
#  Four

## Conversely, when no arguments are given to the null function,
## it operates mostly normally, but as if the function were not there:

local a=1 b=2 c=3; : One; function { : Two; echo $_; print -l $argv; }; print -l $_ Four;
## Outputs:
#  Two

#  One
#  Four
##     ( second line is 'print -l' but $argv is empty

  It would seem this unexpected behavior may be the result of an unfinished shell source where the best shell behavior was not clear to the programmer.  I admit dealing with null functions is a minor point of dilema with script writing, but I have gotten super intricate with the beautiful script design and features made available to me by ZSH, and I have found that the behavior suggested at "Should print" above is the only way that is consistent in a large script where an alias may use a null function for better handling of parameters without interfering with any currently same-name functions, or when a Heredoc is used and one wants to grab the last argument to use as the parameter of an immediately following null function.

--
Micah micah@askmicah.net
AskMicah.Net, Problem Solving Agency

--
Micah micah@askmicah.net
AskMicah.Net, Problem Solving Agency
--------------050902090606070803020704-- --------------070101020004070500030708--