Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 430 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"For" with "usebackq" not using back quotes

#1
I have a batch file which was working quite happily, until the last couple of runs, and now it's not.
The offending code is as follows:

set uncommittedchanges=1
for /f "tokens=* usebackq" %%a in (`"C:\Program Files\Git\cmd\git" -C "\my\git\repository" status`) do (
if "%%a" == "nothing to commit, working directory clean" (
set uncommittedchanges=0
)
)

And the error I am getting is

> 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

I'm sure I haven't made any changes to these lines since it was last working, and I can't see anything wrong with the code as it stands.

Can anyone spot what's wrong, or suggest a setting I may have inadvertently changed that affects usebackq?
Reply

#2
It's a bug of the invoking the child cmd.exe instance.
You need to use a workaround to avoid that the first token uses unescaped spaces.

The simplest way is to use `CALL` as it moves your program-token to the second place, and there it works without problems.

for /f "tokens=* usebackq" %%a in (`CALL "C:\Program Files\Git\cmd\git" -C "\my\git\repository" status`) do (


[Windows start command not able to execute batch file](

[To see links please register here]

)


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through