2016-10-14 07:08:22 +0700, Peter & Kelly Passchier:
> WHich docs?
> If I do "help test" it states: "All file operators except -h and -L are
> acting on the target of a symbolic link, not on the symlink itself, if
> FILE is a symbolic link."
[...]
Yes, to test for file existence, the syntax is
[ -
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" "${a[@]}"
Th
Daniel Colascione wrote:
One such case is Cygwin --- I'm not sure how "contrived" it is. Cygwin
has an old-fashioned non-COW fork, and to add insult to injury,
process creation generally is very slow (~100ms). It pays to eliminate
subshells in that environment.
Given what Cygwin has to work
On Sat, Oct 15, 2016 at 11:12 AM, Marco Ippolito wrote:
> 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?
>
>
On Sat, Oct 15, 2016 at 5:41 PM, lolilolicon wrote:
>
> pop() {
> local -n _a=$1
> printf -v "$2" "${_a[-1]}"
and of course I meant
printf -v "$2" '%s' "${_a[-1]}"
The keyword is nameref if you haven't heard of it, so you can look it
up in the man page :)
On Sat, Oct 15, 2016 at 11:12 AM, Marco Ippolito wrote:
> 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?
>
>
On Sat, Oct 15, 2016 at 7:45 PM, Marco Ippolito wrote:
> On Sat, Oct 15, 2016 at 05:41:32PM +0800, lolilolicon wrote:
>> pop() {
>> local -n _a=$1
>> printf -v "$2" "${_a[-1]}"
>> unset _a[-1]
>> }
>>
>> declare -a a=(a b c)
>> while ((${#a[@]})); do
>> pop a v
>> declare -p a
On Sat, Oct 15, 2016 at 7:58 PM, Marco Ippolito wrote:
> On Sat, Oct 15, 2016 at 07:32:23PM +0800, konsolebox wrote:
>> On Sat, Oct 15, 2016 at 11:12 AM, Marco Ippolito
>> wrote:
>> > Bash has elegant and powerful constructs like `mapfile',
>> > yet it is missing something as easy as an array "p
On Sat, Oct 15, 2016 at 10:50 PM, konsolebox wrote:
>
> My version would be this:
>
> function array_pop { declare -n __a=$1 __v=$2; __v=${__a[-1]}; unset
> '__a[-1]'; }
>
Here's another version which avoids local or nameref variables,
pop() {
[[ -v $1 ]] || return
set -- "$1[-1]" "$2"
On 10/14/16 11:12 PM, Marco Ippolito wrote:
> Bash has elegant and powerful constructs like `mapfile',
> yet it is missing something as easy as an array "pop".
There is source code support for operations like pop and similar. If you
think it's worthwhile, you might look at writing a loadable buil
On 10/15/2016 12:23 AM, L. A. Walsh wrote:
Daniel Colascione wrote:
One such case is Cygwin --- I'm not sure how "contrived" it is. Cygwin
has an old-fashioned non-COW fork, and to add insult to injury,
process creation generally is very slow (~100ms). It pays to eliminate
subshells in that en
Chet Ramey wrote:
> On 9/18/16 11:20 PM, Felix Janda wrote:
>
> >>> Notice that the configure script disables job-control when a run-time
> >>> test (which could easily be a built-time test) fails. So by default,
> >>> a cross-compiled bash will have this bug.
> >>
> >> Which test?
> >
> > I am r
XiaoBing Jiang wrote:
Thank you for your explain!
#!/bin/bash
(cd /tmp && exec sleep 20) &
echo "end"
Then, instead of having:
$ ./foo
end
$ ps f -t pts/5
PID TTY STAT TIME COMMAND
7287 pts/5Ss 0:00 bash
20165 pts/5R+ 0:00
Daniel Colascione wrote:
On 10/15/2016 12:23 AM, L. A. Walsh wrote:
Daniel Colascione wrote:
One such case is Cygwin --- I'm not sure how "contrived" it is. Cygwin
has an old-fashioned non-COW fork, and to add insult to injury,
process creation generally is very slow (~100ms). It pays to elim
On 10/13/16 4:00 AM, Martijn Dekker wrote:
> bash resets BASH_SUBSHELL to 0 when executing an EXIT trap, even if the
> EXIT trap is executed in a subshell.
>
> echo $(trap 'echo $BASH_SUBSHELL' EXIT; echo $BASH_SUBSHELL)
> Actual output: 1 0
> Expected output: 1 1
This is a reasonable suggestion
On 10/11/16 10:14 PM, s7v7nisla...@gmail.com wrote:
> 1. the script to reproduce
> bash-4.4$ cat t.sh
> (cd /tmp && sleep 20) &
>
> echo "end"
>
>
> 2. run it
> bash-4.4$ bash t.sh
> end
>
> 3. script end, but there is a new forked script.
> bash-4.4$ ps -ef | grep t.sh
> 501 50268 1
On 10/10/16 9:57 AM, Stephane Chazelas wrote:
> Now, if we look at the C spec, the way +++ is parsed is down to
> tokenisation that will also go for the longest operator first.
>
> There --test+++3 would be tokenised as -- test ++ + 3 which
> would lead to a syntax error as test++ isn't an lvalue
17 matches
Mail list logo