Tools: setup-unit: ctl edit: Print file name on error
When editing the configuration in-place, it's easy to make a mistake. If the configuration is wrong, it will be passed to the control socket, which will reject it, keeping the old configuration. Those manual edits would be lost, which can make it very uncomfortable to edit in-place. By printing the name of the temporary file, we allow the user to recover the changes. Cc: Liam Crilly <liam@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
@@ -138,6 +138,11 @@ OPTIONS
|
|||||||
__EOF__
|
__EOF__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info()
|
||||||
|
{
|
||||||
|
>&2 echo "$(basename "$0"): info: $*";
|
||||||
|
}
|
||||||
|
|
||||||
warn()
|
warn()
|
||||||
{
|
{
|
||||||
>&2 echo "$(basename "$0"): error: $*";
|
>&2 echo "$(basename "$0"): error: $*";
|
||||||
@@ -430,7 +435,11 @@ unit_ctl_edit()
|
|||||||
|| echo ed;
|
|| echo ed;
|
||||||
) "$tmp";
|
) "$tmp";
|
||||||
|
|
||||||
|
trap "info 'ctl: edit: Invalid configuration saved in <$tmp>.'" ERR
|
||||||
|
|
||||||
unit_ctl_http ---s "$sock" PUT "$req_path" <"$tmp";
|
unit_ctl_http ---s "$sock" PUT "$req_path" <"$tmp";
|
||||||
|
|
||||||
|
trap - ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user