This forum uses cookies. Click X button to hide this message. What is stored? 
Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

button bar command quotes not right

 
Post new topic   Reply to topic    Total Commander Forum Index -> TC7.56(a)/7.57 bug reports (English) Printable version
View previous topic :: View next topic  
Author Message
ppp
Junior Member
Junior Member


Joined: 08 Feb 2012
Posts: 6

PostPosted: Wed Feb 08, 2012 9:39 pm    Post subject: button bar command quotes not right Reply with quote

using commands in button bar, is broken on long filename dirs..
when i use a batch file for command that's in a long filename dir, it doesn't work..[with %P%S for params]
to make it work correctly, i have to put a single double-quote in front of the command: "c:\path to\command.bat
and put closing double-quote in my params: " %P%S
so the command eventually gets to be "c:\path to\command.bat" %P%S when put back together...
otherwise, even echoing out the params with:
for %%1 in (%*) do echo %%1
doesn't work...
so something's knocking off the ending quote from command at top..
[ps i tried using no quotes and still not work when having long filename paths.
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 7859
Location: Russian Federation

PostPosted: Wed Feb 08, 2012 11:39 pm    Post subject: Reply with quote

Every parameter with spaces must be enclosed with quotes (a pair of quotes, one before and one after parameter, not just single quote). In your example:
1st parameter: "c:\path to\command.bat" - a pair of quotes;
2nd etc parameters: %P%S - TC quotes paths with spaces.
So I can't see any problem here.
_________________
TCFS2 + TCFS2Tools: Full-screen mode for TC etc (forum)
TOTALCMD.NET: AskParam, CopyTree, NTLinks, Sudo, VirtualPanel…
Back to top
View user's profile Send private message Send e-mail
ppp
Junior Member
Junior Member


Joined: 08 Feb 2012
Posts: 6

PostPosted: Fri Feb 10, 2012 12:05 am    Post subject: Reply with quote

ahh, but that's just it, if you put 2 quotes on command, it doesn't work..
it's only by putting one up top, and one in params does it work...
hence the bug...
i should be able to put a leading and trailing quote on the command, and none in params line, but it knocks off the trailing one on the command for some reason..so only option is to put it on params line to get it to work properly..
Back to top
View user's profile Send private message
ppp
Junior Member
Junior Member


Joined: 08 Feb 2012
Posts: 6

PostPosted: Wed Feb 15, 2012 5:35 am    Post subject: broken in previous versions as well Reply with quote

i see it's broken in 7.50 as well... Sad

same behavior as mentioned before, 2 quotes on command that needs them don't work, the second quote gets stripped off for some reason..

as i said before, putting 2 quotes on command and none on params line doesn't work..
i have to add a quote on params line because the second one on command line gets chopped off at runtime..

cmd: "command
param: " %P%S
works..

cmd: "command"
param: %P%S
doesn't..Sad
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 7859
Location: Russian Federation

PostPosted: Wed Feb 15, 2012 6:15 am    Post subject: Reply with quote

A-h, I understood reason of your problem. I forget about it last time. Batch files are executed by cmd.exe which works in stupid way in XP:
Code:
cmd.exe /c "command parameters"

Code:
cmd.exe /c ""c:\path to\command.bat" "1.txt" "2.txt" "3.txt""

It requires additional pair of quotes around command and parameters, and it cuts ending quote if first command symbol is quote.

Anyway it is not a TC problem, TC simply tells Windows to execute batch file, and system starts cmd.exe with corrsesponding parameters.

So I recommend to use direct command if you need to start batch file:
Code:
Command: cmd.exe /c ""c:\path to\command.bat"
Parameters: %P%S "

Don't forget last quote, cmd.exe will cut it from last quoted parameter otherwise.
_________________
TCFS2 + TCFS2Tools: Full-screen mode for TC etc (forum)
TOTALCMD.NET: AskParam, CopyTree, NTLinks, Sudo, VirtualPanel…
Back to top
View user's profile Send private message Send e-mail
ppp
Junior Member
Junior Member


Joined: 08 Feb 2012
Posts: 6

PostPosted: Wed Feb 15, 2012 6:45 am    Post subject: Reply with quote

so it looks as if the problem is the quotes around the "command parameters"...who puts those in? they aren't needed at all..
each command/param will have it's own quotes if needed so that extra set surrounding it all is completely unnecessary..
cmd.exe doesn't require it..
try running cmd.exe /c "some command" param1 param2
or cmd.exe /c command param1 param2
no problem..

so wherever the 'extra' set of quotes are coming from is messing the whole thing up..

so why does my workaround of putting second quote on second line work?
the second quote isn't getting 'removed', it's made obsolete by closing itself before the data it's supposed to be quoting:

cmd.exe /c ""c:\path to\command.bat" "1.txt" "2.txt" "3.txt""
equals
cmd.exe /c empty quoted string-"", unquoted path-c:\path to\command.bat, another empty quote-" ", unquoted-1.txt,empty quote-" ",etc,etc...

see what i'm saying?
the extra surrounding quotes make all starting quotes into ending quotes, and vice-versa..
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 7859
Location: Russian Federation

PostPosted: Wed Feb 15, 2012 7:52 am    Post subject: Reply with quote

Yes, they aren't needed for human. But it is Microsoft...

Try to open command line and execute following command:
Code:
cmd.exe /c ""c:\path to\command.bat" "1.txt" "2.txt" "3.txt""

It works fine.

And then try to remove first and last quotes...
Code:
cmd.exe /c "c:\path to\command.bat" "1.txt" "2.txt" "3.txt"

It doesn't work! It says that it can't find a file "c:\path". As I said, it removes first and last characters if they are both quotes (and does nothing if not).

You can check command line that you get by your way (from 1st post), it produces following one:
Code:
cmd /c ""c:\path to\command.bat " C:\1.txt"

I don't know why it works but it works. Stupid cmd.exe's logic (or maybe OS just cuts spaces at the end of filename when cmd opens the file).
_________________
TCFS2 + TCFS2Tools: Full-screen mode for TC etc (forum)
TOTALCMD.NET: AskParam, CopyTree, NTLinks, Sudo, VirtualPanel…
Back to top
View user's profile Send private message Send e-mail
ppp
Junior Member
Junior Member


Joined: 08 Feb 2012
Posts: 6

PostPosted: Wed Feb 15, 2012 2:48 pm    Post subject: Reply with quote

ahh,i see now...only with quotes on params does it mess up...
why using cmd /c?
shellexecutes don't have this problem..[at least i think..lol]

it's just that this is confusing to the user, going against conventional standards and logic..but i understand now it's win's fault..still..

sorry to take up your time on this but it seems a messy way for this otherwise perfect program to have to deal with this simple problem that's apparently been around for ages..

does this not affect regular executables? [.exe]
Back to top
View user's profile Send private message
MVV
Power Member
Power Member


Joined: 03 Aug 2008
Posts: 7859
Location: Russian Federation

PostPosted: Thu Feb 16, 2012 12:13 am    Post subject: Reply with quote

ShellExecute for BAT files executes cmd.exe /c. Very Happy
Batch files are not executables so require special command processor.

In case of regular application only that application controls parameter processing.
_________________
TCFS2 + TCFS2Tools: Full-screen mode for TC etc (forum)
TOTALCMD.NET: AskParam, CopyTree, NTLinks, Sudo, VirtualPanel…
Back to top
View user's profile Send private message Send e-mail
ppp
Junior Member
Junior Member


Joined: 08 Feb 2012
Posts: 6

PostPosted: Thu Feb 16, 2012 1:52 am    Post subject: Reply with quote

well thanx for spreading some light on it..i get around this in for loops by making it @"command" which works fine..
[so first char isn't quote]
TC doesn't let me use that but you might be able to code it in if it does work inside program as well..Smile
[just thought it might be a workaround]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> TC7.56(a)/7.57 bug reports (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group