Re: Passing non-string user defaults through command line arguments
Re: Passing non-string user defaults through command line arguments
- Subject: Re: Passing non-string user defaults through command line arguments
- From: Christiaan Hofman <email@hidden>
- Date: Wed, 06 Apr 2011 01:06:16 +0200
On Apr 6, 2011, at 0:53, Justin C. Walker wrote:
>
> On Apr 5, 2011, at 15:30 , Christiaan Hofman wrote:
>
>>
>> On Apr 6, 2011, at 0:21, Justin C. Walker wrote:
>>
>>> Hi, Christian,
>>>
>>> On Apr 5, 2011, at 09:53 , Christiaan Hofman wrote:
>>>
>>>> Sometimes I want to test my app with a particular value for a user default. I do this by adding a command line argument (in the info for the executable in Xcode) for the user default key. This works for string values, however when the value needs to be something else (e.g. a boolean), I cannot get this to work. Is there a way to do this?
>>>
>>> No. Using the command line (shell), argument passing is always done with strings, so you have to translate in the command. If you want to fuss with fork/exec, you could write a tester that would fuss with the child's address space with (the moral equivalent of) ptrace(), but that's kind of gnarly. Since the kernel does the work in exec(), that's where the semantics of argument-passing is "enforced", so it's just not easy to do (arguments are assumed to be strings, and that is how the kernel deals with them).
>>>
>>> At least, that's my best guess.
>>>
>>> HTH
>>>
>>> Justin
>>>
>>> --
>>> Justin C. Walker, Curmudgeon-At-Large
>>> Institute for the Enhancement of the Director's Income
>>> --------
>>> When LuteFisk is outlawed,
>>> Only outlaws will have LuteFisk
>>
>> Well, I would not expect something like this to work, or at least be feasible. I am more thinking of how app executables handle arguments in general. For instance, the 'defaults' CLT allows passing non-string values to be passed (still as strings from the POV of the executable) by adding extra options like -boolean. Isn't there something similar for app executables?
>
> I think you are assuming that "-boolean" means that the following argument "is" a boolean (whatever that is). In fact, it is just a mechanism to tell the tool how interpret the string that follows (in this case, one of the strings "YES", "NO", "TRUE", or "FALSE"; and only these are permitted).
Well, yes, that's what I am saying...
> It does not mean that the following value is going to be either a (binary) 0 or 1.
>
.. and I'm most definitely not saying or implying anything like that.
> The shell only passes the distinct character sequences that you type in the CLI to the invoked command, *as strings*, via (one of) the exec() calls.
>
> HTH
>
> Justin
>
I am not talking about what the shell does. I am talking about how (or whether) app executables have a way to interpret command line arguments. So I am not talking about the *shell* interpreting arguments as something different than strings (I am well aware that it's not doing that), I am talking about the *app* to interpret them as (C/Cocoa) objects that are not strings.
Christiaan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden