4

I am trying to determine how to resolve an error related to a complex key name in a property list file. The plist file contents are as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>[email protected]</key>
    <dict>
        <key>due</key>
        <date>2018-02-27T05:00:00Z</date>
        <key>start</key>
        <date>2018-02-26T15:08:52Z</date>
    </dict>
</dict>
</plist>

The file was created using plutil and the key/value pair as shown above was accepted/created without an issue. However, if I attempt to remove the key/value (plutil -remove "[email protected]" example.plist), I receive the following error:

example.plist: Could not modify plist, error: No value to remove at key path [email protected]

The reason I believe this has to do with the complex key name is that I can manually change the key name to “Test”, at which point the removal command works as expected.

I tried both quote-enclosing the key name and not, as well as escaping the period and at sign (@), but the same error was observed across all approaches.

2
  • Did you try escaping the '@' as well as the '.'?
    – IconDaemon
    Commented Feb 26, 2018 at 15:51
  • Yes, same result.
    – Ryan D.W.
    Commented Feb 26, 2018 at 15:56

1 Answer 1

1

The solution does involve escaping characters, but it turns out that the plist utility does not respond well to “over-escaping”. If I escape only the periods in the key name and nothing else, it works fine. Specifically, the following command resulted in a successful key deletion:

plutil -remove "19781A58-AAF7-4D5A-AZB2-8D82F2A3ZA97@example\.com" example.plist

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .