[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
declare -f and for (( ... ))
From: |
Thorsten Dahlheimer |
Subject: |
declare -f and for (( ... )) |
Date: |
Sat, 2 Jul 2005 18:59:02 +0200 |
Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: cygwin
Compiler: gcc
Compilation
CFLAGS: -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='i586' -DCONF_OSTYPE='cygwin'
-DCONF_MACHTYPE='i586-pc-cygwin' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/
locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DRECYCLES_PIDS -I. -I/ho
me/xxx/bash/bash-3.0 -I/home/xxx/bash/bash-3.0/include -I/home/xxx/bash/bash
-3.0/lib -O2
uname output: CYGWIN_98-4.10 pcdahl4201 1.5.18s(0.130/4/2) 20050611 15:29:08
i586 unknown unknown Cygwin
Machine Type: i586-pc-cygwin
Bash Version: 3.0
Patch Level: 16
Release Status: release
Description:
When "declare -f" outputs a "for (( exp1; exp2; exp3 ))" command, it inserts
a space after exp1 and exp2. When the output is re-fed into bash, these
extra
spaces become part of the new exp1 and exp2. Repeating this process several
times leads to an accumulation of trailing spaces in exp1 and exp2.
Repeat-By:
$ f() { for (( i=0; i<$1; i++ )); do eval "$(declare -f f)"; done; }
$ declare -f f
f ()
{
for ((i=0 ; i<$1 ; i++ ))
do
eval "$(declare -f f)";
done
}
$ f 20
$ declare -f f
f ()
{
for ((i=0 ; i<$1 ; i++ ))
do
eval "$(declare -f f)";
done
}
Fix:
Either strip trailing whitespace in make_cmd.c:make_arith_for_command()
or print "; " instead of " ; " in print_cmd.c:print_arith_for_command().
Regards,
Thorsten Dahlheimer
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- declare -f and for (( ... )),
Thorsten Dahlheimer <=