batch rename: check dep, handle invalid input

This commit is contained in:
Arun Prakash Jana 2020-03-15 20:26:53 +05:30
parent 03e6d7d553
commit ea2de804f8
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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;