[BUG?] read -n limits bytes, not characters
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -g -O2 uname output: Linux mainserver 2.6.18-5-486 #1 Tue Oct 2 23:38:54 UTC 2007 i686 GNU/Linux Machine Type: i486-pc-linux-gnu Bash Version: 3.1 Patch Level: 17 Release Status: release Description: read -n limits bytes, not characters Repeat-By: read -n1 <<< '(some weird unicode character)' echo "$REPLY" Also tested with 3.2 patchlevel 25 (IIRC). The documentation says /- | -n nchars |read returns after reading nchars characters rather than waiting |for a complete line of input. \- If it's the intended behaviour, the documentation should be changed. I can't provide a fix, sorry. Ah yes, my locale: /- | LANG=de_DE.UTF-8 | LC_CTYPE="de_DE.UTF-8" | LC_NUMERIC="de_DE.UTF-8" | LC_TIME="de_DE.UTF-8" | LC_COLLATE="de_DE.UTF-8" | LC_MONETARY="de_DE.UTF-8" | LC_MESSAGES="de_DE.UTF-8" | LC_PAPER="de_DE.UTF-8" | LC_NAME="de_DE.UTF-8" | LC_ADDRESS="de_DE.UTF-8" | LC_TELEPHONE="de_DE.UTF-8" | LC_MEASUREMENT="de_DE.UTF-8" | LC_IDENTIFICATION="de_DE.UTF-8" | LC_ALL= \- -- This is my life - this is my net! - Jan
Re: [BUG?] read -n limits bytes, not characters
Jan Schampera wrote: > Configuration Information [Automatically generated, do not change]: > Machine: i486 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' > -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib > -g -O2 > uname output: Linux mainserver 2.6.18-5-486 #1 Tue Oct 2 23:38:54 UTC > 2007 i686 GNU/Linux > Machine Type: i486-pc-linux-gnu > > Bash Version: 3.1 > Patch Level: 17 > Release Status: release > > Description: > read -n limits bytes, not characters > > Repeat-By: > read -n1 <<< '(some weird unicode character)' > echo "$REPLY" > > > Also tested with 3.2 patchlevel 25 (IIRC). Thanks for the report. This has already been fixed, and the fix will be in the next release. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Live Strong. No day but today. Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://cnswww.cns.cwru.edu/~chet/
Re: SIGTTOU handling
On Sun, Nov 11, 2007 at 09:56:11PM -0800, [EMAIL PROTECTED] wrote: ... > I had some difficulties getting job control working at > first. I found that having the child process do a > setpgrp() before forking to the bash instance made the > error message about disabling job control go away. You need to call setpgrp or setsid and then open a pty device to establish the pty as a control terminal. -- Mike Stroyan <[EMAIL PROTECTED]>
find help about 'read' built-in command
sorry for my simple problem. i want to store the current working dir to a variable, i write --- pwd | read test --- and i test the variable: --- echo $test --- but the $test is empty. did i make any stupid mistake? 3x for your attention and comment. bash version: GNU bash, version 3.1.17(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc.
Re: find help about 'read' built-in command
龙海涛 wrote: > i want to store the current working dir to a variable, i write The most common way to save the present working directory to a variable would be to use the $(...) form. test=$(pwd) echo $test Try that. Bob
Re: find help about 'read' built-in command
it works. 3x very much. On Tue, 2007-11-13 at 21:51 -0700, Bob Proulx wrote: > 龙海涛 wrote: > > i want to store the current working dir to a variable, i write > > The most common way to save the present working directory to a > variable would be to use the $(...) form. > > test=$(pwd) > echo $test > > Try that. > > Bob > >
how could I execute a set of script in a directoy tree?
i have a directory, like this /testcase /syntaxcheck /test1 0 (common txt file) 0.expected (common txt file) 1 1.expected ... autotest.sh (shell script) /test2 0 0.expected 1 1.expected ... autotest.sh /test3 ... /testn /semantic /test1 0 0.expected 1 1.expected ... autotest.sh /test2 ... /testn ... there are many autotest.sh in every leaf-directory(that is, no sub-directory in this directory. e.g, testcase/syntaxcheck/test1). when i want to execute a auototest.sh, i just came into a leaf-directory, and enter './autotest.sh' command, and all the testcases in this leaf-directory will be examined. but now what i want to do is write a shell script , call all the autotest.sh in every leaf-directory. is it possible or ridiculous?
Re: find help about 'read' built-in command
On Wed, Nov 14, 2007 at 01:11:12PM +0800, 龙海涛 wrote: > it works. > 3x very much. > > On Tue, 2007-11-13 at 21:51 -0700, Bob Proulx wrote: > > > 龙海涛 wrote: > > > i want to store the current working dir to a variable, i write > > > > The most common way to save the present working directory to a > > variable would be to use the $(...) form. > > > > test=$(pwd) > > echo $test By the way, the variable "$PWD" has the same current directory value as "$(pwd)" . Assigning with test=$PWD can be quite a bit faster than using $(pwd) to execute the pwd builtin. $ s=$SECONDS;for (( i=1;i<1;i++ )) ;do d=$(/bin/pwd);done;echo $(($SECONDS-$s)) 23 $ s=$SECONDS;for (( i=1;i<1;i++ )) ;do d=$(pwd);done;echo $(($SECONDS-$s)) 8 $ s=$SECONDS;for (( i=1;i<1;i++ )) ;do d=$PWD;done;echo $(($SECONDS-$s)) 0 The speed difference probably doesn't matter for most situations. -- Mike Stroyan <[EMAIL PROTECTED]>
Re: find help about 'read' built-in command
if you use "$PWD" variable the assignment seems redundant too:) On 11/14/07, Mike Stroyan <[EMAIL PROTECTED]> wrote: > > On Wed, Nov 14, 2007 at 01:11:12PM +0800, 龙海涛 wrote: > > it works. > > 3x very much. > > > > On Tue, 2007-11-13 at 21:51 -0700, Bob Proulx wrote: > > > > > 龙海涛 wrote: > > > > i want to store the current working dir to a variable, i write > > > > > > The most common way to save the present working directory to a > > > variable would be to use the $(...) form. > > > > > > test=$(pwd) > > > echo $test > > By the way, the variable "$PWD" has the same current directory value > as "$(pwd)" . > Assigning with > test=$PWD > can be quite a bit faster than using $(pwd) to execute the pwd builtin. > > $ s=$SECONDS;for (( i=1;i<1;i++ )) ;do d=$(/bin/pwd);done;echo > $(($SECONDS-$s)) > 23 > $ s=$SECONDS;for (( i=1;i<1;i++ )) ;do d=$(pwd);done;echo > $(($SECONDS-$s)) > 8 > $ s=$SECONDS;for (( i=1;i<1;i++ )) ;do d=$PWD;done;echo > $(($SECONDS-$s)) > 0 > > The speed difference probably doesn't matter for most situations. > > -- > Mike Stroyan <[EMAIL PROTECTED]> > > >
Re: how could I execute a set of script in a directoy tree?
On Wed, Nov 14, 2007 at 01:38:01PM +0800, 龙海涛 wrote: ... > but now what i want to do is write a shell script , call all the > autotest.sh in every leaf-directory. You could do that with a recursive function that descends into each directory. Using ( ) around the cd to a subdirectory will return to the previous directory at the closing parenthesis. Looking for autotest.sh files in just leaf directories would be harder than executing those files in all directories of the tree. It would be possible to test for the presence of subdirectories first and suppress execution of autotest.sh in non-leaf directories. But I will assume that you don't actually require that. r () { cd "$1" if [ -x autotest.sh ]; then ./autotest.sh; fi; for d in * do if [ -d "$d" ]; then ( r "$d" ) fi; done } Then run r /testcase to acutally use the recursive function on /testcase. But the find command is very good at doing this as well. find /testcase -name autotest.sh -perm /111 -execdir bash -c ./autotest.sh \; -- Mike Stroyan <[EMAIL PROTECTED]>
Re: find help about 'read' built-in command
On Wed, Nov 14, 2007 at 03:33:25PM +0800, Tatavarty Kalyan wrote: > if you use "$PWD" variable the assignment seems redundant too:) Assigning the value of "$PWD" can be useful for remembering a directory before using cd to change the directory. That leads into the next question about directory tree walking. -- Mike Stroyan <[EMAIL PROTECTED]>