From e42deffac9a03698d32dce0d91c66c91796085e8 Mon Sep 17 00:00:00 2001 From: Peng Li Date: Thu, 23 Jun 2016 01:33:25 +0800 Subject: [PATCH] emacs - improve the install.pl --- emacs.d/install.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/emacs.d/install.pl b/emacs.d/install.pl index 0fbe57e..333531a 100755 --- a/emacs.d/install.pl +++ b/emacs.d/install.pl @@ -4,12 +4,21 @@ use 5.010; use strict; ##my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; -my $date = `date +%m%d`; -chomp $date; +chomp (my $date = `date +%m%d`); if (-e "$ENV{HOME}/.emacs.d" ) { - say "~/.emacs.d folder already exists, rename as ~/.emacs.d_bak_$date"; - ! system "mv", "$ENV{HOME}/.emacs.d", "$ENV{HOME}/.emacs.d_bak_$date" or die; + print "~/.emacs.d folder already exists.\nRename as ~/.emacs.d_bak_$date and continue yes (y) or no (n)? "; + chomp (my $yorn = ); + + while ($yorn ne "y" and $yorn ne "n") { + print "Input y or n: "; + chomp ($yorn = ); + } + + exit if $yorn eq "n"; + + ! system "mv", "$ENV{HOME}/.emacs.d", "$ENV{HOME}/.emacs.d_bak_$date" or die + if $yorn eq "y"; } ## link emacs.d folder -- 2.11.0