瀏覽代碼

batch rename: check dep, handle invalid input

master
Arun Prakash Jana 5 年之前
父節點
當前提交
ea2de804f8
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: A75979F35C080412
共有 2 個文件被更改,包括 11 次插入4 次删除
  1. +6
    -2
      plugins/.nmv
  2. +5
    -2
      src/nnn.c

+ 6
- 2
plugins/.nmv 查看文件

@@ -26,6 +26,10 @@ dst_file=$(mktemp "$TMPDIR/.nnnXXXXXX")
if [ -s "$selection" ]; then if [ -s "$selection" ]; then
printf "Rename 'c'urrent / 's'election? " printf "Rename 'c'urrent / 's'election? "
read -r resp read -r resp

if ! [ "$resp" = "c" ] && ! [ "$resp" = "s" ]; then
exit 1
fi
fi fi


if [ "$resp" = "s" ]; then if [ "$resp" = "s" ]; then
@@ -96,7 +100,7 @@ while read -r num name; do
printf "%s: failed to rename %s to %s: %s\n" "$0" "$name" "$tmp" "$!" > /dev/stderr printf "%s: failed to rename %s to %s: %s\n" "$0" "$name" "$tmp" "$!" > /dev/stderr
exit_status=1 exit_status=1
fi fi
for key in "${!items[@]}"; do for key in "${!items[@]}"; do
if [ "${items[$key]}" = "$name" ]; then if [ "${items[$key]}" = "$name" ]; then
items[$key]="$tmp" items[$key]="$tmp"
@@ -116,7 +120,7 @@ while read -r num name; do
for key in "${!items[@]}"; do for key in "${!items[@]}"; do
items[$key]=$(printf "%s" "${items[$key]}" | sed "s|^$src\(\$\|\/\)|$name\1|") items[$key]=$(printf "%s" "${items[$key]}" | sed "s|^$src\(\$\|\/\)|$name\1|")
done done
printf "'%s' => '%s'\n" "$src" "$name" printf "'%s' => '%s'\n" "$src" "$name"
else else
printf "'%s' -> '%s'\n" "$src" "$name" printf "'%s' -> '%s'\n" "$src" "$name"


+ 5
- 2
src/nnn.c 查看文件

@@ -431,7 +431,8 @@ static uchar g_states;
#define UTIL_FZY 16 #define UTIL_FZY 16
#define UTIL_NTFY 17 #define UTIL_NTFY 17
#define UTIL_CBCP 18 #define UTIL_CBCP 18
#define UTIL_NMV 19 #define UTIL_BASH 19
#define UTIL_NMV 20


/* Utilities to open files, run actions */ /* Utilities to open files, run actions */
static char * const utils[] = { static char * const utils[] = {
@@ -470,6 +471,7 @@ static char * const utils[] = {
"fzy", "fzy",
".ntfy", ".ntfy",
".cbcp", ".cbcp",
"bash",
".nmv", ".nmv",
}; };


@@ -5610,7 +5612,8 @@ nochange:
case SEL_RENAMEMUL: case SEL_RENAMEMUL:
endselection(); endselection();


if (!plugscript(utils[UTIL_NMV], newpath, path, F_CLI) if (!(getutil(utils[UTIL_BASH])
&& plugscript(utils[UTIL_NMV], newpath, path, F_CLI))
&& !batch_rename(path)) { && !batch_rename(path)) {
printwait(messages[MSG_FAILED], &presel); printwait(messages[MSG_FAILED], &presel);
goto nochange; goto nochange;


||||||
x
 
000:0
Loading…
取消
儲存