Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: unshift
- X-seq: zsh-users 29753
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: unshift
- Date: Mon, 1 Apr 2024 09:11:25 -0700
- Archived-at: <https://zsh.org/users/29753>
- In-reply-to: <CAN=4vMrdheVwmTYYUaoZF2mwRO_BLeV+yJU+iUzOUDnfc0cJiQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <f1e0b92a-07b6-46c0-a2d6-6eeda828620b@eastlink.ca> <CAN=4vMrdheVwmTYYUaoZF2mwRO_BLeV+yJU+iUzOUDnfc0cJiQ@mail.gmail.com>
On 2024-04-01 07:38, Roman Perepelitsa wrote:
On Mon, Apr 1, 2024 at 3:52 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
Can we unshift the positional params?
That's an interesting challenge. A start:
Very interesting! Could it be official? Maybe not worth it's weight
but ...
=================================
alias shift='emulate zsh -o typeset_silent -c "local -a _shift_a _shift_n"
_shift_a+=("$@")
_shift_n+=(-$#)
shift'
alias unshift='set -- "${(@)_shift_a[_shift_n[-1],-1]}"
_shift_a[_shift_n[-1],-1]=()
_shift_n[-1]=()'
unshift undoes the last call to `shift [ -p ] [ n ]`. I think (not
entirely sure) that it works with all options. Unfortunately, it does
not work for `shift [ -p ] [ n ] name ...`.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author