Hello,

From a source of mine:

local / typeset = variables declared with local are in scope for the
current shell. The typeset built-in command can also be used to declare 
variables.

export = global variables, called also environment variables, are
set for the currently running shell and any process spawned from that
shell.


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


Can't solve the quiz, any hint?


 
Dan

------
Blog: https://bsd.gaoxio.com - Repo: https://code.5mode.com

Please reply to the mailing-list, leveraging technical stuff.

Reply via email to