extglob features less useful since shell scripts turn them off
Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash-3.2p17si2 -I../bash-3.2p17si2/include -I../bash-3.2p17si2/lib -Os uname output: Linux aa 2.6.39.3-v11 #9 SMP PREEMPT Tue Dec 13 11:07:11 HST 2011 i686 GNU/Linux Machine Type: i686-pc-linux-gnu Bash Version: 3.2 Patch Level: 17 Release Status: release Description: My interactive environment contains some shell functions that are cleaner making use of "extglob on" of the interactive shell. But as soon as any other shell script is run they cause, e.g., aa ~ > bashbug /bin/sh: pushdHelper: line 14: syntax error near unexpected token `(' /bin/sh: pushdHelper: line 14: ` +@([1-9])*([0-9]))' /bin/sh: error importing function definition for `pushdHelper' because the script is running "extglob off" and trying to interpret the functions already in the environment. Repeat-By: Put an extglob feature in a function in the environment and run a shell script. :( Mahalo, Jim
Re: `declare -a NAME` followed by `declare -p NAME`
On 1/4/15 9:31 PM, Ivan Shapovalov wrote: > If an empty array is declared using `declare -a NAME` and then immediately > `declare -p NAME` is invoked, it says there is no such variable. A variable is not set until it is assigned a value. `declare -p name' only finds set variables. > However, the array can be found in output of `declare -p` without NAME given. Yes, since that is supposed to produce output that can recreate all variables with their attributes, even unset variables. This is a common enough request that I have changed the behavior of `declare -p name' for the next bash release, and it will display variables that are not set but have been given attributes. 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: undo local variable with unset
On 1/5/15 3:14 PM, Poor Yorick wrote: > In the following script, the effect of calling f0 is that the value global $i > is still 5, but the effect of calling f1 is that the value of the global $i is > 9. It's nice to be able to create a function like unlocal that moves local > variables out of the way, but I'm wondering if it can be relied on in future > versions: This is a consequence of bash's dynamic scoping and the idea that a local variable should stay local if it's unset at the current scope. I don't have any plans to change that. -- ``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: extglob features less useful since shell scripts turn them off
On 1/5/15 10:20 PM, Jim Thomas wrote: > Configuration Information [Automatically generated, do not change]: > Machine: i686 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL > -DHAVE_CONFIG_H -I. -I../bash-3.2p17si2 -I../bash-3.2p17si2/include > -I../bash-3.2p17si2/lib -Os > uname output: Linux aa 2.6.39.3-v11 #9 SMP PREEMPT Tue Dec 13 11:07:11 HST > 2011 i686 GNU/Linux > Machine Type: i686-pc-linux-gnu > > Bash Version: 3.2 > Patch Level: 17 > Release Status: release > > Description: > My interactive environment contains some shell functions that are > cleaner making use of "extglob on" of the interactive shell. But > as soon as any other shell script is run they cause, e.g., > > aa ~ > bashbug > /bin/sh: pushdHelper: line 14: syntax error near unexpected token `(' > /bin/sh: pushdHelper: line 14: ` +@([1-9])*([0-9]))' > /bin/sh: error importing function definition for `pushdHelper' > > because the script is running "extglob off" and trying to interpret > the functions already in the environment. > > Repeat-By: > Put an extglob feature in a function in the environment and run > a shell script. You can export SHELLOPTS; that's how that variable should be used. It's up to how bash orders the environment as to whether it will be read by the time the imported functions need the extglob setting. The variable is mostly intended to be used by shell scripts. 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/