chenall / grub4dos

外部命令和工具源码:https://github.com/chenall/grubutils 下载:
http://grub4dos.chenall.net
GNU General Public License v2.0
650 stars 136 forks source link

command line parameter value with = signs #131

Open steve6375 opened 7 years ago

steve6375 commented 7 years ago

I came across this issue when I had a filename of /WinntSetup/enabled=1 present. I was using a batch file to enumerate all files in the folder using ls | call :copyfiles the file enabled=1 is treated as two parameters enabled and 1

Example:

test.bat

!BAT
echo %1 %2 %3 %4

Then enter command:

/test.bat aaa enabled=1 bbb

output:

aaa enabled 1 bbb

Is there any way to fix this?

steve6375 commented 7 years ago

Maybe set an internal parameter so only spaces and tabs are recognised as parameter separators? Or a new grub4dos command, parsecmd=0 for default behaviour and parsecmd=1 for space\tab only?

jianliulin commented 7 years ago

/test.bat aaa “enabled=1” bbb

steve6375 commented 7 years ago

Thanks, but I am using ls | call :copyfiles

so there are no quotes around each 'value' because ls does not use quotes in the output.

jianliulin commented 7 years ago

ls | set aa= call :copyfiles "%aa%"

steve6375 commented 7 years ago

ls | set aa= call :copyfiles "%aa%"

That does not work as the list is "aaa bbb cccc=1 dddd" so the whole list is passed as one value. The subroutine uses %1 %2 etc. to get each pathname, so if I remove the " " then it still gets cccc and 1 as separate variables.

steve6375 commented 7 years ago

If a space is in the filename or path, then it is escaped in ls command output e.g. ccc\ ddd.iso So maybe one solution would be to also escape the = sign in the output of the ls command? e.g. doris\=1.iso

I am not sure if this would affect compatibility??? image