John Kearney wrote:
echo ${a[@]:1:2}
---
Thanks!...I couldn't believe there wasn't some way to do
it, but darned if I couldn't think of it or find it for that matter...
sigh.
Thanks again!
On Wed, Apr 25, 2012 at 04:46:02PM -0700, Linda Walsh wrote:
> I would guess (without looking at the codE), that
> when you do a local, it creates another copy of 'var' at the end of an
> array.
> like var[0][1]
> so global is at 0, and local is at 1.
I'm pretty sure bash doesn't use a multidimen
On Mon, Apr 23, 2012 at 04:56:09PM +0800, Clark Wang wrote:
> When I revisit this 2 years old thread I don't understand why following
> foo() function does not output the global var:
>
> $ cat foo.sh
> var=global
> foo()
> {
> local var=foo
> unset var
> echo foo: $var
> }
> bar_unset(
On 26 Apr 2012, at 01:18, Linda Walsh wrote:
>
> Ishtar:> echo "${b[*]}"
Please note that expanding array elements using [*] is usually NOT what anyone
wants. Be careful about recommending it to anyone.
"${b[*]}" # This throws away any usefulness of the array by merging all the
array elements
On 26 Apr 2012, at 06:30, John Kearney wrote:
> Am 26.04.2012 06:26, schrieb Linda Walsh:
>> I know I can get
>> a="abcdef" echo "${a[2:4]}" = cde
>>
>> how do I do:
>> typeset -a a=(apple berry cherry date); then get:
>>
>> echo ${a[1:2]} = "berry" "cherry" ( non-grouped args)
>>
>> I tried to
I added a bit if code to show some things that I did and did not expect.
#!/bin/bash
var=global
foo() {
echo
local var=foo
unset var
echo ${FUNCNAME[@]}: $var
displayVar
displayVarfoo() {
echo ${FUNCNAME[@]}: $var
}
displayVarfoo
}
bar_unset() {
unset
On Thu, Apr 26, 2012 at 05:54:27PM +0200, Maarten Billemont wrote:
> On 26 Apr 2012, at 01:18, Linda Walsh wrote:
> >
> > Ishtar:> echo "${b[*]}"
>
> You should always recommend the "${b[@]}" variant. "${b[*]}" is rarely
> useful in the event that your intent is to merge the array into a single
On Thu, Apr 26, 2012 at 12:02:20PM -0600, Bill Gradwohl wrote:
> bar_unset() {
> unset var
> echo ${FUNCNAME[@]}: $var
> displayVar
> displayVarbar_unset() {
>echo ${FUNCNAME[@]}: $var
> }
> displayVarbar_unset
> echo
> newVar=bar_unset
> }
> When newVar is
On Thu, Apr 26, 2012 at 12:49 PM, Greg Wooledge wrote:
> I don't see this as a surprise. It's how you return values from functions
> in bash. Pick a global variable (r, ret, whatever you want) and stuff the
> return value into that. You can even declare your "r" locally somewhere
> so that the
On Thu, Apr 26, 2012 at 01:37:57PM -0600, Bill Gradwohl wrote:
> When the child creates a global to pass back information, and then
> terminates, the parent had no control over that variables creation and is
> now stuck with something in the global name space that via the hierarchy of
> calls, it d
Maybe there should be a limit, MAX_INTERACTIVE_COMMAND_LENGTH on how
much can be fed into one bash command line, any more and bash should
beep and reject the whole command.
Otherwise an innocent middle click, or SHIFT INSERT slip of the fingers
could paste an entire book out of the clipboard, into
This would also save on later having to clean the massive blob out of
the history list.
On Thu, Apr 26, 2012 at 2:16 PM, Greg Wooledge wrote:
> If the goal is to see the contents of an array, I'd use one of these,
> depending on how much detail I need:
>
> printf '<%s> ' "${array[@]}"; echo
>
> declare -p array
>
Or i'd use the args function Greg has shown before:
args() { printf
On Tuesday 24 April 2012 15:49:57 Chet Ramey wrote:
> On 4/24/12 10:46 AM, Mike Frysinger wrote:
> > On Tuesday 24 April 2012 08:23:04 Chet Ramey wrote:
> >> On 4/24/12 12:00 AM, Mike Frysinger wrote:
> OK, so you've stripped the local readline copy out of the source tree?
> >>>
> >>> yes
> >
On Fri, 27 Apr 2012 04:18:21 +0800, jida...@jidanni.org wrote:
> This would also save on later having to clean the massive blob out of
> the history list.
And, the Murphy's Law case(s) where one of the pasted lines
contains a 'legitimate' linux command...
Been there -- got a T-shirt.
Jonesy
Configuration Information [Automatically generated, do not change]:
Machine: mips64el
OS: linux-gnu
Compiler: mips64el-unknown-linux-gnu-gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='mips64el'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='mips64el-unknown-linux-gnu'
-DCONF_VENDOR='unkno
On 4/26/12 4:50 PM, Joseph Graham wrote:
> Bash Version: 4.2
> Patch Level: 24
> Release Status: release
>
> Description:
> Arrays defined in a function with declare -ag are not
> available outside the function if an assignment is done with the
> declaration, though it works if the assignment is
On Fri, Apr 27, 2012 at 02:02, Bill Gradwohl wrote:
>
> So, if you want to make sure a sub
> function can't touch a variable, put another function in between that
> localises and then unsets the variable.
>
Sounds interesting. Will see if I can take advantage of this in future. :)
>
>
> --
> Bi
On Fri, Apr 27, 2012 at 02:49, Greg Wooledge wrote:
>
> I don't see this as a surprise. It's how you return values from functions
> in bash. Pick a global variable (r, ret, whatever you want) and stuff the
> return value into that. You can even declare your "r" locally somewhere
> so that the
Maarten Billemont wrote:
On 26 Apr 2012, at 01:18, Linda Walsh wrote:
Ishtar:> echo "${b[*]}"
Please note that expanding array elements using [*] is usually NOT what anyone
wants.
---
It was exactly what I wanted for my example to work. Please don't suggest
non-working solutions to th
On Thursday 26 April 2012 23:47:39 Linda Walsh wrote:
> Anything else you wanna tell me NEVER/ALWAYS to do?
try ALWAYS being polite. but i guess that'll NEVER happen.
oh well, thankfully kmail can auto-mute based on sender.
-mike
signature.asc
Description: This is a digitally signed message pa
21 matches
Mail list logo