On 10/24/16 7:32 PM, L. A. Walsh wrote:
>I don't understand the ambiguity. If param= "#obj[@]", then it
> is clear to me that the user wants the length of an array named "obj".
Stop there. In something like ${#obj[@]}, `param' is `obj[@]'. The
`${#param}' is a clearly-defined word expansio
On 10/25/16 4:09 PM, Stuart Shelton wrote:
> The cases appear, purely by inspection, to be:
>
> Not declared: trivially, `typeset -p` doesn’t include the value;
> Declared (even as local) but unassigned: `typeset -p` includes "declare --
> varname";
> Declared and assigned: `typeset -p` includes
On 10/25/16 12:40 AM, Martijn Dekker wrote:
> Op 25-10-16 om 00:42 schreef Stuart Shelton:
>> Failing this, is there any alternative to ‘typeset’ to list a
>> variable declared as local to a function but which has not yet been
>> assigned a value?
>
> Try simply testing the exit status of 'typeset
On 10/20/16 7:44 PM, Jack Kuan wrote:
> Thanks for replying.
>
> I was expecting that in the second iteration of the loop, the
> local var=var_123 command would make var a normal variable again with
> value "var_123"
This is the bad assumption. You didn't unset `var' before doing this, so
it re
On 10/25/16 12:19 PM, Stuart Shelton wrote:
> Thanks for the suggestion!
>
> However, it doesn’t appear to be able to detect local variables (is this
> intentional or a bug?):
It's a bug; fixed in bash-4.4.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
`
On 10/20/16 2:45 PM, kjk...@gmail.com wrote:
> set -x
>
> var_123=123
> f() {
> while (( $# )); do
> shift
> local var=var_123
> local -n var=$var; : status is $?
> local -p
> : var is $var
> done
> }
>
> f one two
>
>
> Running above script gives
Op 28-10-16 om 15:00 schreef Chet Ramey:
> On 10/25/16 12:40 AM, Martijn Dekker wrote:
>> Try simply testing the exit status of 'typeset -p' or 'declare -p'. If
>> the variable is not declared, it exits unsuccessfully.
>>
>> if typeset -p "$var" >/dev/null 2>&1 && [[ ! -v $var ]]
>> then ..
Chet Ramey wrote:
On 10/24/16 7:32 PM, L. A. Walsh wrote:
I don't understand the ambiguity. If param= "#obj[@]", then it
is clear to me that the user wants the length of an array named "obj".
Stop there. In something like ${#obj[@]}, `param' is `obj[@]'. The
`${#param}' is a c
thank you for the insight, it's very helpful!
On Oct 28, 2016 10:01 AM, "Chet Ramey" wrote:
On 10/20/16 2:45 PM, kjk...@gmail.com wrote:
> set -x
>
> var_123=123
> f() {
> while (( $# )); do
> shift
> local var=var_123
> local -n var=$var; : status is $?
> loc
On 10/28/16 3:43 PM, L. A. Walsh wrote:
>
>Please, I'm not running in posix mode, so how would their rules
> apply?
Because you're using `bash', not `walsh'?
Bash is a posix shell. Would the bash documentation convince you? You
could go read that instead.
> Just because posix defines
Chet Ramey wrote:
Come on, don't be willfully obtuse. You know better than this. Posix mode
doesn't mean "turning it off does everything the way Linda wants."
No, but claiming posix as a backing for features running that are
not running with posix-mode set, is equally obtuse.
Bash is not l
11 matches
Mail list logo