zsh-workers
 help / color / mirror / code / Atom feed
* Shift arguments
       [not found] ` <20121031142546.529e1709@pwslap01u.europe.root.pri>
@ 2012-10-31 15:01   ` Peter Stephenson
  2012-10-31 16:33     ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 2012-10-31 15:01 UTC (permalink / raw)
  To: Zsh Hackers' List

On Wed, 31 Oct 2012 14:25:46 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> It looks like this is hitting some pathology in memory management to
> do with the argument array (which is being shifted at that line).

Looking at the code, I found a feature of shift I'm not sure I like:

% integer foo=3
% set -- one two three four five six
% shift foo
% print $*
four five six

In other words, if the argument to shift is a parameter that isn't an
array, it's used to give a mathematical value with which to shift the
positional parameters.  That seems confusing.

pws


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Shift arguments
  2012-10-31 15:01   ` Shift arguments Peter Stephenson
@ 2012-10-31 16:33     ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2012-10-31 16:33 UTC (permalink / raw)
  To: Zsh Hackers' List

On Oct 31,  3:01pm, Peter Stephenson wrote:
}
} % integer foo=3
} % set -- one two three four five six
} % shift foo
} % print $*
} four five six
} 
} In other words, if the argument to shift is a parameter that isn't an
} array, it's used to give a mathematical value with which to shift the
} positional parameters.  That seems confusing.

I can't disagree that it's confusing, but the idea is that you can give
any math expression there, e.g. "shift 7-foo" would shift by 4.  This
is in the same category as passing math expressions to "return".

It's always been like that ...


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-31 16:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20121031134007.GA9731@localhost.localdomain>
     [not found] ` <20121031142546.529e1709@pwslap01u.europe.root.pri>
2012-10-31 15:01   ` Shift arguments Peter Stephenson
2012-10-31 16:33     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).