Skip to content

Instantly share code, notes, and snippets.

@glarizza
Created January 7, 2012 17:19
Show Gist options
  • Select an option

  • Save glarizza/1575359 to your computer and use it in GitHub Desktop.

Select an option

Save glarizza/1575359 to your computer and use it in GitHub Desktop.
Testing plists w/ defaults read
The-Big-Mac:~ glarizza$ defaults read /Applications/TextEdit.app/Contents/Info NSServices
(
{
NSMenuItem = {
default = "New TextEdit Window Containing Selection";
};
NSMessage = openSelection;
NSPortName = TextEdit;
NSSendTypes = (
"com.apple.flat-rtfd",
"public.rtf",
"public.plain-text"
);
},
{
NSMenuItem = {
default = "Open Selected File in TextEdit";
};
NSMessage = openFile;
NSPortName = TextEdit;
NSRequiredContext = {
NSTextContent = FilePath;
};
NSSendTypes = (
"public.plain-text"
);
}
)
The-Big-Mac:~ glarizza$ echo $?
0
The-Big-Mac:~ glarizza$ defaults read /Applications/TextEdit.app/Contents/Info NSSt
2012-01-07 09:14:59.031 defaults[17816:903]
The domain/default pair of (/Applications/TextEdit.app/Contents/Info, NSSt) does not exist
The-Big-Mac:~ glarizza$ echo $?
1
in IRB on the client:
>> puts 'true' if system("defaults read /Applications/TextEdit.app/Contents/Info NSServices > /dev/null")
true
=> nil
>> puts 'true' if system("defaults read /Applications/TextEdit.app/Contents/Info Nsbad > /dev/null")
2012-01-07 09:17:30.471 defaults[17841:903]
The domain/default pair of (/Applications/TextEdit.app/Contents/Info, Nsbad) does not exist
=> nil
## Try this
exec { "/bin/echo 'test'":
onlyif => "/usr/bin/defaults read /Applications/TextEdit.app/Contents/Info NSServices",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment