Consider a preference plist with a dict that contains an array:
Let's create it:
defaults write org.my.test '{aDict = {anArray = ();};}'
Then read it back to see the structure better:
$defaults read org.my.test
{
aDict = {
anArray = (
);
};
}
Now, how do I add a value to anArray
using the defaults write
command?
I know that there is the -array-add
type for adding values to an array, but how do I specify the key path to the array element?
I've tried this, but that doesn't work:
defaults write org.my.test aDict.anArray -array-add "a value"
In fact, I need to add a non-string type, so I also need to be able to specify the type, e.g. -bool YES
.
(Note: I cannot use PlistBuddy nor plutil as this needs to affect live preferences)