I can not understand how to read a file with nmake

I am doing something like this:

all: @SET /p filecontent= < somefile.txt @echo %filecontent% 

However, the filecontent variable does not seem to contain the contents of somefile.txt .

+1
source share
3 answers

Just make sure somefile.txt is in the valid nmake syntax and then !include . In this way:

 c:>type somefile.txt PASSWORD=secret c:>type makefile !INCLUDE somefile.txt !MESSAGE Password is [$(PASSWORD)] c:>nmake -nologo Password is [secret] 
+1
source

You can read a file that is not a valid nmake file using !INCLUDE . For example, if we have a version file that contains one line of text, we can do this:

 //version file 1.2.4 //makefile VERSION= \ !INCLUDE <version> 

It does not work if the file contains more than one line.

+1
source

You can try something like this:

 # ---- vitaly.mak ---- target1: # create and invoke a temporary cmd file @<<mygetpassword.cmd @echo off setlocal @SET /p filecontent= < secret.txt @echo %filecontent% endlocal << #--- END --- 

I think the cmd / bat file in nmake.exe cannot affect the nmake environment . Therefore, you must use the password that you captured from the secret.txt file in the temporary cmd file.

-1
source

Source: https://habr.com/ru/post/1332497/


All Articles