Export to GitHub

grub4dos-chenall - issue #76

variable is giving wrong value


Posted on Feb 8, 2012 by Happy Bear

What steps will reproduce the problem? set * set x=8 set x=2 && set y=%x% && set

What is the expected output? What do you see instead? x=2 y=8 #??????

What version of the product are you using? any

Comment #1

Posted on Feb 9, 2012 by Happy Hippo

Firstly you must understand the manner that variables are expanded and how batch scripts are interpreted.

Batch scripts are read line-by-line. Any variables are replaced with their values and then the line is executed; variables are updated after each line is interpreted.

Is the same as WINDOWS CMD.EXE, try it in cmd.exe you will get the same result。

Comment #2

Posted on Mar 18, 2012 by Happy Bear

OK! Thanks! but:

set * set x=8 set x=2 && call set y=%x^% #x=2 y=2 OK!

Comment #3

Posted on Mar 19, 2012 by Happy Hippo

Yes,because call will get new line to run.

Status: Done

Labels:
Type-Defect Priority-Medium