Re: [PATCH] fdisk: quit immediately with a single CTRL-D

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 From my point of view it's bad idea to quit immediately, the CTRL-D
 could be typo and then you lost all unwritten changes. The ideal
 solution is to ask ("Do you really want to quit?" y/n/^D) before you
 call exit(). (Note that fdisk is often called from scripts, so
 CTRL-D has to be acceptable answer to the question.)

    Karel

On Sun, Dec 19, 2010 at 06:11:50PM +0100, Francesco Cosoleto wrote:
> Signed-off-by: Francesco Cosoleto <cosoleto@xxxxxxxxx>
> ---
>  fdisk/fdisk.c |   15 +++------------
>  1 files changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
> index 5a69437..72bb361 100644
> --- a/fdisk/fdisk.c
> +++ b/fdisk/fdisk.c
> @@ -1320,19 +1320,10 @@ got_dos_table:
>  int
>  read_line(void)
>  {
> -	static int got_eof = 0;
> -
>  	line_ptr = line_buffer;
> -	if (!fgets(line_buffer, LINE_LENGTH, stdin)) {
> -		if (feof(stdin))
> -			got_eof++; 	/* user typed ^D ? */
> -		if (got_eof >= 3) {
> -			fflush(stdout);
> -			fprintf(stderr, _("\ngot EOF thrice - exiting..\n"));
> -			exit(1);
> -		}
> -		return 0;
> -	}
> +	if (!fgets(line_buffer, LINE_LENGTH, stdin))
> +		exit(1);
> +
>  	while (*line_ptr && !isgraph(*line_ptr))
>  		line_ptr++;
>  	return *line_ptr;
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux