bash keeps too much data in memory
Configuration Information [Automatically generated, do not change]: Machine: i386 OS: freebsd6.2 Compiler: cc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='freebsd6.2' -DCONF_MACHTYPE='i386-portbld-freebsd6.2' -DCONF_VENDOR='portbld' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -I/usr/local/include -O2 -fno-strict-aliasing -pipe -march=pentium3 uname output: FreeBSD wojtek.tensor.gdynia.pl 6.3-RELEASE-p1 FreeBSD 6.3-RELEASE-p1 #0: Thu Feb 28 00:27:45 CET 2008 [EMAIL PROTECTED]:/usr2/src/sys/i386/compile/p234 i386 Machine Type: i386-portbld-freebsd6.2 Bash Version: 3.2 Patch Level: 33 Release Status: release Description: bash sometimes keeps in memory everything it outputs with echo. Repeat-By: create BIG text file, lots of lines, at least 100MB do while read ll;do echo $RANDOM $RANDOM $ll;done outfile then from other console observe how bash grows, will and with something above filesize - which suggest it keeps in memory all it echoed. Fix: none
Re: bash keeps too much data in memory
Wojciech Puchar <[EMAIL PROTECTED]> writes: > Description: > bash sometimes keeps in memory everything it outputs with echo. > > Repeat-By: > create BIG text file, lots of lines, at least 100MB > do > while read ll;do echo $RANDOM $RANDOM $ll;done outfile > then from other console observe how bash grows, will and with something > above filesize - which suggest it keeps in memory all it echoed. Does this patch help? --- builtins/read.def |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) Index: builtins/read.def === --- builtins/read.def.orig 2007-11-10 01:20:45.0 +0100 +++ builtins/read.def 2007-11-10 02:03:38.0 +0100 @@ -134,7 +134,7 @@ read_builtin (list) intmax_t intval; char c; char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname; - char *e, *t, *t1, *ps2; + char *e, *t, *t1, *t2, *ps2; struct stat tsb; SHELL_VAR *var; #if defined (ARRAY_VARS) @@ -677,12 +677,14 @@ add_char: if (*input_string) { t1 = input_string; - t = get_word_from_string (&input_string, ifs_chars, &e); + t2 = get_word_from_string (&input_string, ifs_chars, &e); if (*input_string == 0) - input_string = t; + input_string = t2; else input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape); } + else +t2 = NULL; #endif if (saw_escape) @@ -696,6 +698,7 @@ add_char: stupidly_hack_special_variables (list->word->word); if (var) VUNSETATTR (var, att_invisible); + FREE (t2); xfree (orig_input_string); return (retval); Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: bash keeps too much data in memory
works fine! , but patch didn't (1 hunk of 3 failed). i patched it manually (bash-3.2.tar.gz with all patches from ftp.gnu.org) and compiled. bug is fixed. thanks the working patch below. if you'll put this patch on ftp or not, both please tell me and the name, i will add the fix to FreeBSD ports. --- builtins/read.def.orig Thu Mar 13 22:26:42 2008 +++ builtins/read.def Thu Mar 13 22:41:25 2008 @@ -134,7 +134,7 @@ intmax_t intval; char c; char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname; - char *e, *t, *t1, *ps2; + char *e, *t, *t1, *t2, *ps2; struct stat tsb; SHELL_VAR *var; #if defined (ARRAY_VARS) @@ -677,9 +677,9 @@ if (*input_string) { t1 = input_string; - t = get_word_from_string (&input_string, ifs_chars, &e); + t2 = get_word_from_string (&input_string, ifs_chars, &e); if (*input_string == 0) - input_string = t; + input_string = t2; else input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape); } @@ -696,6 +696,7 @@ stupidly_hack_special_variables (list->word->word); if (var) VUNSETATTR (var, att_invisible); + FREE (t2); xfree (orig_input_string); return (retval);
would you give me a hand with a simple 'if' bash script?
Execuse me, would you give me a hand with a simple 'if' bash script? I want to make folders "00", "01",...,"20" and copy existing files file_00, file_01,,file_20 to each folder. Thank you very much. - for (( i = 1 ; i <= 20; i++ )) do if [ $i -gt 10 ]; then foldername = $i filename = "file_" filename = $filename$i else foldername = "0"$i ## filename ="file_0" ## file = $filename$i ## fi done -- View this message in context: http://www.nabble.com/would-you-give-me-a-hand-with-a-simple-%27if%27-bash-script--tp16037981p16037981.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: would you give me a hand with a simple 'if' bash script?
hawa wrote: > Execuse me, would you give me a hand with a simple 'if' bash script? > I want to make folders "00", "01",...,"20" and > copy existing files file_00, file_01,,file_20 to each folder. Something like this (UNTESTED): for n in $(seq -w 0 20); do mkdir $n mv file_$n $n/ done Or did you mean to copy all files to each folder? for n in $(seq -w 0 20); do mkdir $n cp file_* $n/ done Bob
Re: would you give me a hand with a simple 'if' bash script?
hawa wrote: > Execuse me, would you give me a hand with a simple 'if' bash script? > I want to make folders "00", "01",...,"20" and > copy existing files file_00, file_01,,file_20 to each folder. > Thank you very much. > > > > - > for (( i = 1 ; i <= 20; i++ )) > do > > if [ $i -gt 10 ]; then foldername = $i > filename = "file_" > filename = $filename$i > else > foldername = "0"$i ## > filename ="file_0" ## > file = $filename$i ## > fi > > done untested: for (( i = 1 ; i <= 20; i++ )) do foldername=$(printf %02d $i) filename=$(printf file_%02d $i) # now, do whatever you want with $filename # and $foldername (cp, mv, rm, ...) done J.