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: "Justin C. Walker" <email@hidden>
- Date: Tue, 05 Apr 2011 15:53:19 -0700
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). It does not mean that the following value is going to be either a (binary) 0 or 1.
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
--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Enhancement of the Director's Income
--------
When LuteFisk is outlawed,
Only outlaws will have LuteFisk
--------
_______________________________________________
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