bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature request: allow shif [n] with n > $#


From: konsolebox
Subject: Re: feature request: allow shif [n] with n > $#
Date: Sat, 13 Apr 2019 09:54:45 +0800

On Sat, Apr 13, 2019, 9:43 AM Robert Elz <address@hidden> wrote:

>     Date:        Thu, 11 Apr 2019 19:05:56 -0400
>     From:        Chet Ramey <address@hidden>
>     Message-ID:  <address@hidden>
>
>   | If you want to be sure to shift out all existing parameters, use
>   | `shift $#'. If you want something else, you can add logic to cap the
>   | argument passed to `shift' at $#.
>
> I agree.
>
> Except "set --" is less work all around than "shift $#"
>
> In general:
>
>         [ "$ARG" -lt "$#" ] && shift "$ARG" || set --


shift "$(( n < $# ? n : $# ))"

--
konsolebox


reply via email to

[Prev in Thread] Current Thread [Next in Thread]