Re: readline expansion: 'cp $v/TAB' - 'cp \$v/' (no expansion) - why?
On 7/7/12 11:39 AM, Jason Vas Dias wrote: Next Question : - any plans to allow us to export array or associative store variables ? ie. represent them in *environ passed to programs with an integration with glibc getenv() to support this ? There is already code -- commented out -- to export array variables in a format that resembles a compound array assignment, and code -- still commented out -- in bash to understand them. It's not enabled because the chance for obscure collisions with similarly-formed environment variables is non-negligible and doesn't have an elegant solution. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: readline expansion: 'cp $v/TAB' - 'cp \$v/' (no expansion) - why?
On 7/8/12 4:14 PM, Jason Vas Dias wrote: There is already code -- commented out -- to export array variables in a format that resembles a compound array assignment, and code -- still commented out -- in bash to understand them. It's not enabled because the chance for obscure collisions with similarly-formed environment variables is non-negligible and doesn't have an elegant solution. Chet Aha ! Interesting - which source file ? bash-4.2.29: variables.c:371; variables.c:3479. The way I'd do it (and do it with shells that do not understand indexed / associative arrays), is, for array my_array and member index having value $item : Add or Set an item: eval 'export my_array_'${item_deref}'_'${index}'='$item Get an item: eval '$my_array_'${item_deref}'_'${index} 'Remove' an item eval 'undef my_array_'${item_deref}'_'${index}' and I'd suggest having item_deref=('.' or '__' or '@') also known to glibc getenv() or a new getenv_x() function in glibc so that programs can use them . Any plans along these lines ? No. I'm not sure it's a good idea to create large numbers of environment variables for exported arrays with large numbers of elements. That can slow exec() down and lead to weird errors if the ARG_MAX limit, which includes the environment, is exceeded. The same space problem exists for the (currently-disabled) bash mechanism, granted. I'm also not particularly interested in glibc-only interfaces. That's one of the reasons that I'd like a solution to this to require only bash and be more-or-less agnostic to other programs that might scan the environment. And is there any way for the current bash to support exported variables whose names contain '.' ? No. Bash-4.2 doesn't allow variables with characters outside the set [_a-zA-Z][_a-zA-Z0-9]*. It will pass environment strings that aren't valid variable names through to the programs it invokes. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: readline expansion: 'cp $v/TAB' - 'cp \$v/' (no expansion) - why?
Sorry, I tried 4.2-29(2) at home and it DOES correctly complete '$SRC/TAB' - of courrse, it helps if $SRC contains the name of an existing directory, which it did not at work. Thanks ! a most interesting list . Next Question : - any plans to allow us to export array or associative store variables ? ie. represent them in *environ passed to programs with an integration with glibc getenv() to support this ? Thanks Regards, Jason On Thu, Jul 5, 2012 at 12:59 PM, Jason Vas Dias jason.vas.d...@gmail.com wrote: hi Eric - thanks for your response, but bash-4.2.29(2), just built from latest patches from gnu on x86_64 ubuntu, does NOT restore the old behavior , but now refuses to tab-expand at all - 'cat $SRC/TAB' on the command line still produces no output. Is there some option I need to give to enable it? Thanks! On 5 Jul 2012 13:24, Eric Blake ebl...@redhat.com wrote: On 07/05/2012 04:58 AM, Jason Vas Dias wrote: Now it changes the input string into 'less \$SRC/' and prevents tab expansion as would be done without use of any variables. Would anyone know how to restore the old behavior with bash 4.2.2 + readline 6.2 (linux ubuntu 12.04) ? Yep - upgrade to bash 4.2.29 (that is, patchlevel 2 is missing the fix in patchlevel 29 that restores the behavior you want). ftp://ftp.gnu.org/pub/gnu/bash/bash-4.2-patches/bash42-029 This topic comes up frequently on this list. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org
readline expansion: 'cp $v/TAB' - 'cp \$v/' (no expansion) - why?
my #1 bash gripe is that newer versions do not expand command lines containing '$' in emacs readline editing mode. I used to be able to do: $ export SRC=../somedir $ less ${SRC}/TAB (TAB meaning press horizontal tab key ) and emacs mode readline would expand, displaying the contents of ../somedir . Now it changes the input string into 'less \$SRC/' and prevents tab expansion as would be done without use of any variables. Would anyone know how to restore the old behavior with bash 4.2.2 + readline 6.2 (linux ubuntu 12.04) ? Thanks Regards, Jason
Re: readline expansion: 'cp $v/TAB' - 'cp \$v/' (no expansion) - why?
On 07/05/2012 04:58 AM, Jason Vas Dias wrote: Now it changes the input string into 'less \$SRC/' and prevents tab expansion as would be done without use of any variables. Would anyone know how to restore the old behavior with bash 4.2.2 + readline 6.2 (linux ubuntu 12.04) ? Yep - upgrade to bash 4.2.29 (that is, patchlevel 2 is missing the fix in patchlevel 29 that restores the behavior you want). ftp://ftp.gnu.org/pub/gnu/bash/bash-4.2-patches/bash42-029 This topic comes up frequently on this list. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: readline expansion: 'cp $v/TAB' - 'cp \$v/' (no expansion) - why?
hi Eric - thanks for your response, but bash-4.2.29(2), just built from latest patches from gnu on x86_64 ubuntu, does NOT restore the old behavior , but now refuses to tab-expand at all - 'cat $SRC/TAB' on the command line still produces no output. Is there some option I need to give to enable it? Thanks! On 5 Jul 2012 13:24, Eric Blake ebl...@redhat.com wrote: On 07/05/2012 04:58 AM, Jason Vas Dias wrote: Now it changes the input string into 'less \$SRC/' and prevents tab expansion as would be done without use of any variables. Would anyone know how to restore the old behavior with bash 4.2.2 + readline 6.2 (linux ubuntu 12.04) ? Yep - upgrade to bash 4.2.29 (that is, patchlevel 2 is missing the fix in patchlevel 29 that restores the behavior you want). ftp://ftp.gnu.org/pub/gnu/bash/bash-4.2-patches/bash42-029 This topic comes up frequently on this list. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: readline expansion: 'cp $v/TAB' - 'cp \$v/' (no expansion) - why?
On 7/5/12 7:59 AM, Jason Vas Dias wrote: hi Eric - thanks for your response, but bash-4.2.29(2), just built from latest patches from gnu on x86_64 ubuntu, does NOT restore the old behavior , but now refuses to tab-expand at all - 'cat $SRC/TAB' on the command line still produces no output. Is there some option I need to give to enable it? Thanks! Make sure you're not using programmable completion to eliminate that as a possible problem. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/