[arch-projects] [netcfg] [PATCH 1/2] Defensively remove temporary file in EXIT trap
Dave Reisner
d at falconindy.com
Thu Jun 21 10:00:53 EDT 2012
On Thu, Jun 21, 2012 at 02:52:16PM +0200, Henrik Hallberg wrote:
> Signed-off-by: Henrik Hallberg <halhen at k2h.se>
> ---
> scripts/netcfg-menu | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/netcfg-menu b/scripts/netcfg-menu
> index d0db762..a3bab94 100755
> --- a/scripts/netcfg-menu
> +++ b/scripts/netcfg-menu
> @@ -30,6 +30,7 @@ fi
> # if no default yet, use the first entry
> [[ -z "$DEFAULT" ]] && DEFAULT="${profiles[0]}"
> ANSWER=$(mktemp --tmpdir menu.XXXXXXXX) || exit 1
> +trap "rm -f $ANSWER" EXIT
This needs to be evaluated at the time the trap is called, not when the
trap is declared.
trap 'rm -f "$ANSWER"' EXIT
Better yet, do this properly and avoid the need for a temporary file.
>
> # Set timeout
> if [[ -z "$1" ]]; then
> @@ -60,7 +61,6 @@ case $ret in
> exit_err "Abnormal ret code from dialog: $ret"
> ;;
> esac
> -rm -f "$ANSWER" # JP: add -f
> exit $ret # JP: exit with caught $?
>
> # vim: ft=sh ts=4 et sw=4:
> --
> 1.7.11
>
More information about the arch-projects
mailing list