From 39348ff32f90718fa73d9008a774d091acd8bbca Mon Sep 17 00:00:00 2001 From: LAN-TW Date: Thu, 2 Feb 2012 22:11:28 +0800 Subject: =?UTF-8?q?bash=5Finclude:=20mvfile=20=E9=96=8B=E5=A7=8B=E6=94=AF?= =?UTF-8?q?=E6=8F=B4=20sudo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash_include | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'bash_include') diff --git a/bash_include b/bash_include index 136a05a..6442ade 100644 --- a/bash_include +++ b/bash_include @@ -751,23 +751,27 @@ function set_console_title () function mvfile () { - while [ "$1" ] + split_arguments "$@" + local -i i=0 + while [ "${arglist[$i]}" ] do - if [ '!' -e "$1" ] + if [ '!' -e "${arglist[$i]}" ] then - printf "\e[33mWarning\e[m: $1 does not exist.\n" - shift + printf "\e[33mWarning\e[m: ${arglist[$i]} does not exist.\n" + i=$i+1 continue fi - echo "Old name: $1" - read -p "New name: " -e -i "$1" new_file_name - if [ "$new_file_name" ] && [ "$1" != "$new_file_name" ] + echo "Old name: ${arglist[$i]}" + read -p "New name: " -e -i "${arglist[$i]}" new_file_name + if [ "$new_file_name" ] && [ "${arglist[$i]}" != "$new_file_name" ] then - \mv -iv "$1" "$new_file_name" - history -s mv -iv "$1" "$new_file_name" + "${prefixlist[@]}" mv -iv "${arglist[$i]}" "$new_file_name" + history -s "${prefixlist[@]}" mv -iv "${arglist[$i]}" "$new_file_name" fi - shift + i=$i+1 done + unset arglist + unset prefixlist unset new_file_name } @@ -833,7 +837,7 @@ function help_function () convert_to_html filename ... keep_sudo_credential [seconds] mkscreenacl username ... - mvfile + mvfile filename ... [-- sudo_prefix] prehistory_backup set_console_title x split_arguments [arguments ...] -- cgit v1.2.3