Execute defaults command with Shell functions

Since we introduced the Shell functions in MBS FileMaker Plugin, we find new uses each day. The following example uses the defaults command line tool to add preferences for the Dock application:
Set Variable [ $error ; Value: "" ]
Set Variable [ $result ; Value: "" ]
Set Variable [ $shell ; Value: MBS( "Shell.New" ) ]
Set Variable [ $s ; Value: MBS( "Shell.Execute"; $shell; "/usr/bin/defaults"; "write"; "com.apple.dock"; "persistent-apps"; "-array-add"; "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Font Book.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>") ]
Set Variable [ $s ; Value: MBS( "Shell.Wait"; $shell; 2) ]
Set Variable [ $error ; Value: $error & MBS( "Shell.ReadErrorText"; $shell; "UTF-8") ]
Set Variable [ $result ; Value: $result & MBS( "Shell.ReadOutputText"; $shell; "UTF-8") ]
Set Variable [ $s ; Value: MBS( "Shell.Execute"; $shell; "/usr/bin/killall"; "Dock") ]
Set Variable [ $s ; Value: MBS( "Shell.Wait"; $shell; 2) ]
Set Variable [ $error ; Value: $error & MBS( "Shell.ReadErrorText"; $shell; "UTF-8") ]
Set Variable [ $result ; Value: $result & MBS( "Shell.ReadOutputText"; $shell; "UTF-8") ]
Set Field [ Shell::Error ; MBS( "Text.ReplaceNewline"; $error; 1) ]
Set Field [ Shell::Output ; MBS( "Text.ReplaceNewline"; $result; 1) ]
Set Variable [ $r ; Value: MBS("Shell.Release"; $shell) ]
