Ask the user if he wants to delete the archive
This commit is contained in:
parent
d5ba8fac02
commit
d8e2d6cd2f
1 changed files with 19 additions and 4 deletions
|
@ -16,16 +16,16 @@ function ssh-import
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
set file "$argv[1]"
|
set archive_file "$argv[1]"
|
||||||
if test (count $argv) -ge 2
|
if test (count $argv) -ge 2
|
||||||
# Check if usage is respected
|
# Check if usage is respected
|
||||||
echo "$current_name: too much arguments." 1>&2
|
echo "$current_name: too much arguments." 1>&2
|
||||||
return 1
|
return 1
|
||||||
else if not test -e "$file"
|
else if not test -e "$archive_file"
|
||||||
# Check if file exists
|
# Check if file exists
|
||||||
echo "$current_name: file doesn't exists." 1>&2
|
echo "$current_name: file doesn't exists." 1>&2
|
||||||
return 1
|
return 1
|
||||||
else if not test $(string sub --start=-3 "$file") = zip
|
else if not test $(string sub --start=-3 "$archive_file") = zip
|
||||||
# Check if file have .zip extension
|
# Check if file have .zip extension
|
||||||
echo "$current_name: file isn't a zip archive." 1>&2
|
echo "$current_name: file isn't a zip archive." 1>&2
|
||||||
return 1
|
return 1
|
||||||
|
@ -41,5 +41,20 @@ function ssh-import
|
||||||
# Update and overwrite the .ssh directory with the archive content
|
# Update and overwrite the .ssh directory with the archive content
|
||||||
# Using modification date, and new files are added
|
# Using modification date, and new files are added
|
||||||
# Files removed aren't tracked
|
# Files removed aren't tracked
|
||||||
unzip -uo "$file" -d $ssh_directory
|
unzip -uo "$archive_file" -d $ssh_directory
|
||||||
|
|
||||||
|
# Ask user if he want to delete the archive now that it has been imported
|
||||||
|
while read --nchars 1 -l response --prompt-str="Wanna delete the archive? (y/n)"
|
||||||
|
or return 1 # if the read was aborted with ctrl-c/ctrl-d
|
||||||
|
switch $response
|
||||||
|
case y Y
|
||||||
|
rm $archive_file
|
||||||
|
echo "$current_name: archive deleted."
|
||||||
|
break
|
||||||
|
case n N
|
||||||
|
break
|
||||||
|
case '*'
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue