diff options
author | KlzXS <klzx+github@klzx.cf> | 2020-11-07 22:39:34 +0000 |
---|---|---|
committer | KlzXS <klzx+github@klzx.cf> | 2020-11-07 22:39:34 +0000 |
commit | d4c1986a95bc6441c7e749f7ea0697add7dc94fa (patch) | |
tree | 9df2d5afeac7c6eaa3a79950fcc7c4563b85c037 /plugins | |
parent | e8803b8b6452a5e62e4c1f7910144a803241362d (diff) | |
download | nnn-d4c1986a95bc6441c7e749f7ea0697add7dc94fa.tar.gz |
sed fixes
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/dups | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/plugins/dups b/plugins/dups index e409a5e..5aacbeb 100755 --- a/plugins/dups +++ b/plugins/dups @@ -25,7 +25,7 @@ printf "\ ## After editiing this file you will be prompted to remove some of them. ## You can choose between removing all the commented out files, all the uncommented ones or none at all. ## All the lines begining with '##','#md5sum' or 'md5sum' will be ignored either way. -## If you choose to remove, you will be given a choice between removing with force or interactively for each file. +## If you choose to remove, you will be given a choice between removing with force or interactively for each file.\n " > "$tmpfile" # shellcheck disable=SC2016 @@ -39,7 +39,7 @@ g :loop N /.*\n$/!b loop -p' | sed -E 's/^.{32} (.*) d[0-9]*$/\1/' > "$tmpfile" +p' | sed -E 's/^.{32} (.*) d[0-9]*$/\1/' >> "$tmpfile" "$EDITOR" "$tmpfile" @@ -47,9 +47,9 @@ printf "Remove commented files? (yes/no/abort) [default=a]: " read -r commented if [ "$commented" = "y" ]; then - sedcmd="/^(##|#?md5sum|[^#]).*/d" + sedcmd="/^(##|#?md5sum|[^#]).*/d; /^$/d; s/^# *(.*)$/\1/" elif [ "$commented" = "n" ]; then - sedcmd="/^(#|#?md5sum).*/d" + sedcmd="/^(#|#?md5sum).*/d; /^$/d; s/^ *(.*)$/\1/" else printf "Press any key to exit" read -r _ @@ -59,10 +59,13 @@ fi printf "Remove with force or interactive? (f/i) [default=i]: " read -r force -rmcmd="'rm -$force \"\$0\" \"\$@\" < /dev/tty'" - -# shellcheck disable=SC2016 -sed -e "$sedcmd" "$tmpfile" | tr '\n' '\0' | xargs -0 sh -c "$rmcmd" +if [ "$force" = "f" ]; then + #shellcheck disable=SC2016 + sed -E "$sedcmd" "$tmpfile" | tr '\n' '\0' | xargs -0 sh -c 'rm -f "$0" "$@" </dev/tty' +else + #shellcheck disable=SC2016 + sed -E "$sedcmd" "$tmpfile" | tr '\n' '\0' | xargs -0 sh -c 'rm -i "$0" "$@" </dev/tty' +fi rm "$tmpfile" |