[Top][All Lists]

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

Add support for array .pop()

From: Marco Ippolito
Subject: Add support for array .pop()
Date: Sat, 15 Oct 2016 05:12:15 +0200

Bash has elegant and powerful constructs like `mapfile',
yet it is missing something as easy as an array "pop".

Extract the last value of an array at the same time as
removing it from the array.

Is this the best one can do?

$ a=(1 2 3); v=${a[-1]}; unset 'a[-1]'; printf '%s\n' "$v" "address@hidden"

The 2-step approach gets tiresome after a while.

For positional parameters, it _does_ have `shift'...
... maybe it could add a `pop`, somehow?

reply via email to

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