Feature #2275
closedndnsec-delete: report success or failure
Description
In some cases ndnsec-delete
doesn't really delete anything (either something doesn't exist or identity is "default").
The status of the action needs to be reported on terminal:
- "Identity XXX, all its keys and certificates has been deleted"
- "Identity XXX does not exist"
- "Cannot delete default identity XXX"
Updated by Junxiao Shi almost 10 years ago
- Tracker changed from Task to Feature
- Subject changed from ndnsec-delete doesn't report success or failure to ndnsec-delete: report success or failure
I agree with this feature in general, but:
- stdout shall have a consistent, machine readable format, such as the list of identities/certificates that have been deleted, which is empty if nothing is deleted; this allows the output to be analyzed by a script easily
- stderr could have human readable messages, which can be suppressed by
-q
option - return value shall reflect success or reason for failure
Updated by Yingdi Yu almost 10 years ago
- Status changed from New to Code review
- % Done changed from 0 to 100
Updated by Junxiao Shi almost 10 years ago
The solution in commit 0359e88fee08f21c61d03a2982b3584bc4aafbc0 causes ndnsec-delete
to return 1 for the following conditions:
- incorrect command line syntax
- entity to be deleted does not exist
- other exceptions
The second condition is worth a distinct return value.
In some cases the caller only wants to ensure the entity does not exist after the call, regardless of whether it exists before the call.
Giving this condition a distinct return value allows the caller to achieve this goal.
I suggest returning 1 on the non-existent condition, and returning 2 for other conditions.
This is better than returning 2 on the non-existent condition, and returning 1 for other conditions, because it allows the caller to simply write [[ $? -le 1 ]]
in bash without first assigning $?
to a named variable.
Updated by Alex Afanasyev almost 10 years ago
- Status changed from Code review to Closed