[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash 2.05b xargs question
From: |
Paul Jarc |
Subject: |
Re: bash 2.05b xargs question |
Date: |
Wed, 19 Mar 2003 13:59:44 -0500 |
User-agent: |
Gnus/5.090017 (Oort Gnus v0.17) Emacs/21.2 (gnu/linux) |
David Pease <dpease@davisvision.com> wrote:
> $ echo 1 |xargs -ip echo $[ p ] p
> 0 1
>
> Is this the correct behavior?
Yes. The arithmetic expansion is done by bash before xargs is
executed. $p is presumably not set, so $[p] is 0. You can see the
arguments actually seen by xargs like this:
$ bash -xc 'echo 1 | xargs -ip echo $[ p ] p'
+ echo 1
+ xargs -ip echo 0 p
0 1
Here's how you could get the behavior you want:
echo 1 | xargs -n 1 bash -c 'echo $[$0] $0'
paul