I have just fixed things using the let to fix $y behavior in my *pipe
technique* but nothing change: inside the pipe loop variable $arg (or
$arg1 $arg2 $arg3) seems to have a different scope than from outside
the pipe loop (passing by the environment too) ..
Dan <d...@nnnne-o-o-o.com> wrote:
> By *the local boat* should be:
>
> local mypath="/home"
> local myfile="file.txt"
> local line=""
> local arg
> local y=0
>
> y=0
> arg[$y]="hello"
> y=$y+1
> arg[$y]="dan"
> y=$y+1
> arg[$y]="nuggetsman"
>
> #debug
> echo ${arg[0]}
> echo ${arg[1]}
> echo ${arg[2]}
>
> y=0
>
> cat $mypath'/'$myfile |
> while read -r line
> do
>
> #debug
> echo "y="$y
> echo "line="$line
>
> arg[$y]=$line
>
> #debug
> echo "arg[y]="${arg[$y]}
>
> y=$y+1
> done
>
> #debug
> echo ${arg[0]}
> echo ${arg[1]}
> echo ${arg[2]}
>
> exit 1
>
>
> By *the export boat* should be:
>
> local mypath="/home"
> local myfile="file.txt"
>
> export arg1="hello"
> export arg2="dan"
> export arg3="nuggetsman"
> export line=""
> export y=0
>
> #debug
> echo $arg1
> echo $arg2
> echo $arg3
>
> y=0
>
> cat $mypath'/'$myfile |
> while read -r line
> do
> #debug
> echo "y="$y
> echo "line="$line
>
> case $y in
> 0 )
> export arg1=$line
>
> #debug
> echo "arg1="$arg1
> ;;
> 1 )
> export arg2=$line
>
> #debug
> echo "arg2="$arg2
> ;;
> 2 )
> export arg3=$line
>
> #debug
> echo "arg3="$arg3
> ;;
> esac
>
> y=$y+1
> done
>
> #debug
> echo $arg1
> echo $arg2
> echo $arg3
>
> exit 1
>
>
> The final result is always:
>
> hello
> dan
> nuggetsman
Dan
------
Blog: https://bsd.gaoxio.com - Repo: https://code.5mode.com
Please reply to the mailing-list, leveraging technical stuff.