Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14670

Re: comment on RFE: 'shift'' [N] ARRAYNAME

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Dennis Williamson <dennistwilliamson@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: comment on RFE: 'shift'' [N] ARRAYNAME
Date Thu, 27 Sep 2018 07:42:20 -0500
Lines 46
Approved bug-bash@gnu.org
Message-ID <mailman.1387.1538052159.1284.bug-bash@gnu.org> (permalink)
References <5BAAD017.4010806@tlinx.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
X-Trace usenet.stanford.edu 1538052159 2935 208.118.235.17 (27 Sep 2018 12:42:39 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash <bug-bash@gnu.org>
To Linda Walsh <bash@tlinx.org>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fVKELsGRi3sOu6EhpO3G8gv+DuqWXz5cdY/GcKcm4DU=; b=LRE61r1nFxRH7EHUBybOKnhgtvxHI5qP3z++CObm+XPm9D2WXljGcO0tFaKAXOapqh 5BfQZGShPugSRZut5+xLMtDzl1I1HLWHFBeo7Gk2m4lmXEnuHWLvxlX01SeuTft1Vvfe 0Fjp+uUfbVrw4fEyqh9NK63BjytIb+KNRGhCfhpsOE8cSKuBYjHKf3im5jNOOvKZRoKx rnArAYJKL+CWSPDFUVcqu3j0jQcE40RSpv0aGGnmfbkIzTd+aTUFbozwf2WV3QQ660gV nNfwRahWt4OXk9IfvxE6e7QWxr/1QAQymRd986zRRTfbuSTf81iT5fdVGwlCrjlIXZgm PVng==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fVKELsGRi3sOu6EhpO3G8gv+DuqWXz5cdY/GcKcm4DU=; b=IGRRzuq8HfBH+kKR4TwJB1r9bKH64lBYEyZIjcYDZnbuojjqjonMxtZfTmmW1b4Ugr lr4DPe3pryEsDMX0paEAuUmjkyyh5FLyEdTOc7rpxfMol462k8AEsVfaxbv6ngFdhu8R RkzP4yTszGCYWcPVIwhqdkty1belIxGqPAShnONFNqkn2xlrEw5PZ5Y/zvWwLJdip9eZ QSEoYWD/IkGcy8frUg+fG6MmYBmgpxkwTXkDEkLGFIgxsBILdOgWB0RjyYgRMyXK03K1 6kzBtI82+W6auHwisvVU6JJJzP/fcFjyDkxiswfCCe2Wet+4O2FSmsKV3lYRQOXj7Og6 oOag==
X-Gm-Message-State ABuFfoiQ2Bf8orXTAL5rwfillqe+Oi87FLqd5BXIGRlNdQKUFKccqFpf AiW4PtrG+ewq5YRmndiqwaZLHeFNOju5wlz6Fjsf
X-Google-Smtp-Source ACcGV62dIdtt35TJ9osD5wE4bsjv1cIbeGDf+Sn8CIXsh2dTuOFIrmlyigHO0JlT533aXOUAtqeUpPOFloD3ir5O4w0=
X-Received by 2002:a9d:30b:: with SMTP id 11-v6mr2005397otv.95.1538052152890; Thu, 27 Sep 2018 05:42:32 -0700 (PDT)
In-Reply-To <5BAAD017.4010806@tlinx.org>
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2607:f8b0:4864:20::32b
X-Content-Filtered-By Mailman/MimeDel 2.1.21
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14670

Show key headers only | View raw


On Tue, Sep 25, 2018, 7:17 PM L A Walsh <bash@tlinx.org> wrote:

> It struck me as it might be convenient if 'shift' could take an optional
> arrayname as an argument.  Would that be possible or would it cause some
> incompatibility?
>
> i.e.
>
> >  set one two three four five
> >  dcl -a ARGV=("$@")
> >  shift ARGV
> >  echo "${ARGV[@]}"
> two three four five
> >  shift 2 ARGV
> four five
>
> I know it can be done with a function, but with more mess.
> I used (maybe there's a better way, but...):
>
> (in my lib file ArFuncs.shh, that I can include)
>
> [include stdalias]
> #[include Types] #if type-checking include Types+line below
> lshift () {
>   (($#)) || return 1
>   int nshift=1
>   if [[ $1 =~ ^[0-9]+$ ]]; then nshift=$1; shift;fi
>   #if ! isArr $1; then echo >&2 "Need arrayname"; return 1; fi
>   my ar=$1; shift
>   my h="$ar[@]"
>   set "${!h}"
>   shift $nshift
>   eval "${ar}=("$@")"
> }; export -f lshift
>
>
>
> "my" - What is this, Perl?

array_shift=2
arr=("${arr[@]:$array_shift}")

Done.


>

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: comment on RFE: 'shift'' [N] ARRAYNAME Dennis Williamson <dennistwilliamson@gmail.com> - 2018-09-27 07:42 -0500

csiph-web