[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test '-v' - associative vs. normal array discrepancy - a bug ?
From: |
Greg Wooledge |
Subject: |
Re: test '-v' - associative vs. normal array discrepancy - a bug ? |
Date: |
Wed, 19 Nov 2014 17:16:44 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Nov 19, 2014 at 11:05:51PM +0100, Piotr Grzybowski wrote:
> On Wed, Nov 19, 2014 at 10:51 PM, Eduardo A. Bustamante López
> <dualbus@gmail.com> wrote:
> > is_defined3() {
> > { declare -p -- "$1" && ! declare -fp -- "$1"; } 2>/dev/null >&2
> > }
>
> I dont know, but looks like a reusable code to me.
No, it fails if the argument is both a function AND a variable.
imadev:~$ is_defined3() { { declare -p -- "$1" && ! declare -fp -- "$1"; }
2>/dev/null >&2; }
imadev:~$ declare -p foo
bash: declare: foo: not found
imadev:~$ is_defined3 foo ; echo $?
1
So far, so good. But....
imadev:~$ foo() { echo foo; }
imadev:~$ foo=bar
imadev:~$ is_defined3 foo ; echo $?
1
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, (continued)
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Chet Ramey, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Eduardo A . Bustamante López, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?,
Greg Wooledge <=
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Eduardo A . Bustamante López, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Stephane Chazelas, 2014/11/20
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, konsolebox, 2014/11/20
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, konsolebox, 2014/11/20
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/20
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, konsolebox, 2014/11/20
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Stephane Chazelas, 2014/11/21