topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 7:45 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Double quoted command line arguments  (Read 5526 times)

daddydave

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 867
  • test
    • View Profile
    • Donate to Member
Double quoted command line arguments
« on: May 24, 2010, 07:03 PM »
You know how command line arguments with spaces have to be in double quotes in Windows for pretty much any program?

taskdaddy "@@Errand Go to the market"


Are the double quotes locale dependent, i.e.
taskdaddy «@@Errand Allez à la marché»


or do "English" double quotes work in every region?

The formal second person when talking to yourself is probably wrong grammatically, but you get the idea.





« Last Edit: May 24, 2010, 07:05 PM by daddydave »

Jibz

  • Developer
  • Joined in 2005
  • ***
  • Posts: 1,187
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #1 on: May 25, 2010, 01:58 AM »
I don't think I've seen a command line parser that uses anything but " (ascii 34 or the unicode equivalent) as double quote.

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #2 on: May 25, 2010, 02:05 AM »
Agreed.  I've only ever seen straight-up ".

daddydave

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 867
  • test
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #3 on: May 25, 2010, 08:56 AM »
@skwire, @Jibz:

Thanks, that makes life a little easier. :)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #4 on: May 25, 2010, 12:54 PM »
It might be interesting to ask on a dedicated Windows group/forum like this one for W7:

http://www.sevenforums.com/

Maybe someone using Japanese version of Windows could tell you.  Should be a simple matter of checking an entry to see if the param is the usual "%1" or if there's some other token besides  the ".

I'm no unicode expert but I think the code for the 127 characters is the same in unicode so they probably just stuck with the quote.  I remember in Delphi when you created an ActiveX Control from a TWinControl the strings were automatically converted to wstring type(equivalent to BSTRING type,) but only the first 127 char codes were handled automatically.  All the compiler had to do was use 2 bytes instead of 1 for each character.


« Last Edit: May 25, 2010, 12:56 PM by MilesAhead »

Eóin

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #5 on: May 25, 2010, 01:11 PM »
Generally speaking with technical details like that localizations issues aren't considered. Why? Well I guess the discussion had here is relevant.

After all, quote's were just an arbitrary choice, undoubtedly related to the fact that a lot of programming languages use them to denote string. For example, still in English, “Unicode Quotes” aren't accepted either.

daddydave

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 867
  • test
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #6 on: May 25, 2010, 01:58 PM »
Well I guess the discussion had here is relevant.

That's a funny discussion. Makes me glad HTML wasn't invented by an Urdu speaker, we'd all have to type from right to left (and in a different alphabet). With regard to color vs. colour, I've seen some libraries where they used defines or inline functions or something so either would work.

EDIT
This quote is suitable for framing:

"Yes, I am proposing that if you don't want your native language mutated in another land, don't bring it with you when you conquer it. " --app103
« Last Edit: May 25, 2010, 02:12 PM by daddydave »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #7 on: May 25, 2010, 04:55 PM »
Of course the whole question would be obviated if the moron, er, I mean, decision-maker, didn't allow spaces in file paths in the first place. A lot of OS work perfectly fine without them.  I guess it's too easy if you don't have to test every string for an embedded space.

daddydave

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 867
  • test
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #8 on: May 25, 2010, 05:11 PM »
Of course the whole question would be obviated if the moron, er, I mean, decision-maker, didn't allow spaces in file paths in the first place. A lot of OS work perfectly fine without them.  I guess it's too easy if you don't have to test every string for an embedded space.


What OS doesn't allow spaces in the file paths?

Besides, not all command line arguments are file paths so that wouldn't solve the problem.

I'd have to say

taskdaddy @@ErrandGotothemarket
and then it would show up that way in Outlook, too.
« Last Edit: May 25, 2010, 05:13 PM by daddydave »

daddydave

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 867
  • test
    • View Profile
    • Donate to Member
Re: Double quoted command line arguments
« Reply #9 on: May 25, 2010, 05:24 PM »
Here is a little background.

I kicked off TaskDaddy as a GUI app.

Then I thought, it would be nice to take the task specification on the command line as well, and using the same syntax that the GUI uses.

Then I started adding command line parameters and my custom command line parsing started to break down when I started thinking of command line option switches I wanted to add.

So I started using a third party set of functions to simplify the command line parsing. I decided to require the main argument to be in quotes so that that it would pick it up as a single argument.

So overnight the syntax changed from

taskdaddy @@Errand Go to the market


to

taskdaddy "@@Errand Go to the market"
.

But there is one problem.

What if I have this?

taskdaddy @@Someday Make another "King Kong" sequel 


I'm back to multiple parameters again because I can't have double quotes within double quotes.

So one way to tackle it, is that if a parameter has a space in it, go ahead and add double quotes to the outside of it. Additionally, concatenate all the non-option parameters into one (with spaces added, of course).

There is a flaw in this, though (can you spot it?), but that was my thinking.


« Last Edit: May 25, 2010, 05:29 PM by daddydave »