user3733648
user3733648

Reputation: 1333

What does this statement do

I have a batch file which contains a line of code

set /p bom=<%YUI_FOLDER%\bom

which I am unable to understand what this line do

Upvotes: 1

Views: 70

Answers (2)

jkalden
jkalden

Reputation: 1588

In this script I found an annotated piece of code which pretty much explanes what the line should do:

REM Unicode transformation.
REM Report files should be readable in Windows Notepad editor.
REM Example DOS characters: ”„á‚
REM Example WIN characters: öäüßé
REM Create Unicode files with BOM.
REM Having set the current codepage to 1252, ...
REM then the UTF-16LE BOM can be created by the command ...
REM SET /P BOM=ÿþ<NUL 2>NUL >"UnicodeFile.txt"

So, in the YUI Compressor Bash Script Manager this line is used to create the variable bom which is checked whether it is utf8 or cp1252 or whatever...

Upvotes: -1

MC ND
MC ND

Reputation: 70923

set /p var=[prompt] is the usual way in batch files to retrieve input from the user, showing a prompt (if present) and storing the user response in the variable.

set /p reads its data from a stream, usually the console, but a pipe or a redirection can be readed in the same way.

In this case, the set /p will read its data from a redirected file. The < is a input redirector operator. It indicates that the stream to read from will not be the console, but a file indicated after the operator.

In this case the file is called bom and is located inside a folder. The path to this folder is stored in the environment variable %YUI_FOLDER%

So set /p bom=<%YUI_FOLDER%\bom means: read the content of the file bom from the folder referenced in the variable %YUI_FOLDER% and store the data retrieved into the bom variable

set /p will retrieve data from the file until the end of file, a end of line or the read buffer is full, what happens first.

Upvotes: 5

Related Questions