interactive test faulty
Bash version 4.1.7(2) Slackware 13.1.0 (32bit) (2.6.33.4-smp kernel, i686 AMD Athlon II X2 250 processor) $- does not work as documented example, from a bash shell *echo e"$-"* output is *ehimBH* put echo "$-" in a oneline bash script called test and make executable *./test* output is *ehB* this should include the "i" in the output as the shell _is_ interactive *echo hi|./test * output is *e* this is as expected input is not from a tty either the functionality of bash is not correct or the meaning of interactive is not clear. eg a script called test2 as follows #!/bin/bash echo "type in your name" read USERNAME echo "hello $USERNAME" called via the shell by typing ./test2 is interactive, but $- special variable doe not indicate it is. regards, Tim
Re: interactive test faulty
On Thu, Mar 22, 2012 at 2:06 PM, Tim Dickson wrote: > eg a script called test2 as follows > #!/bin/bash > echo "type in your name" > read USERNAME > echo "hello $USERNAME" > > called via the shell by typing > ./test2 > is interactive, but $- special variable doe not indicate it is. It's not interactive, the kernel calls the script like: /bin/bash test2 that is, it is called with an argument and the manual says: "An interactive shell is one started without non-option arguments "
Re: interactive test faulty
On Thu, Mar 22, 2012 at 12:06:24PM +, Tim Dickson wrote: > put echo "$-" in a oneline bash script called test and make executable > *./test* > output is *ehB* > this should include the "i" in the output as the shell _is_ interactive No, a script is by definition a non-interactive shell. > *echo hi|./test * > output is *e* > this is as expected input is not from a tty Are you confusing "interactive" with "has a terminal as standard input"? > either the functionality of bash is not correct or the meaning of > interactive is not clear. >From the manual, An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. If you run a script like ./test, then the kernel invokes bash with the script name as a non-option argument (i.e., "/bin/bash ./test"). So that shell is not interactive.
COMP_POINT is not set correctly when there is non-ascii characters in the command line.
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin' -DSTANDARD_UTILS_PATH='/usr/bin:/bin:/usr/sbin:/sbin' -DSYS_BASHRC='/etc/bash.bashrc' -DSYS_BASH_LOGOUT='/etc/bash.bash_logout' uname output: Linux yuyichao-PC 3.2.11-1-ARCH #1 SMP PREEMPT Thu Mar 15 09:19:02 CET 2012 x86_64 Intel(R) Core(TM)2 Duo CPU T9600 @ 2.80GHz GenuineIntel GNU/Linux Machine Type: x86_64-unknown-linux-gnu Bash Version: 4.2 Patch Level: 24 Release Status: release Description: The variable COMP_POINT is actually set to the size (not the length) of the command line before the cursor, whereas ${#COMP_LINE} returns the length of the string. This behavior make it hard to determine where the cursor is when the commandline contain non-ascii characters and it is NOT consistent with the statement in bash(1) which says these two are the same when the cursor is at the end of the line. Repeat-By: $ a() { COMPREPLY=('' "${COMP_POINT}" "${#COMP_LINE}"); } $ complete -F a a $ a å a from the generated completion list, we can see two different numbers, which means these two value are not the same!!