]> git.plutz.net Git - bookman/commitdiff
quicker rename function
authorpaul <paul@plutz.net>
Sun, 3 Dec 2017 15:04:54 +0000 (15:04 +0000)
committerpaul <paul@plutz.net>
Sun, 3 Dec 2017 15:04:54 +0000 (15:04 +0000)
svn path=/trunk/; revision=10

index.cgi

index 00006da66746bf8dd3121a10175ed3c2f3021989..12caed196f2da889f783a410cbdcce921618b9c1 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -160,10 +160,7 @@ case "$(GET action)" in
     fid="$(POST fid | checkid)"
     file="${BDB}/${fid}.bm"
     if [ "$(POST control)" = confirm -a -n "$name" -a -f "$file" ]; then
     fid="$(POST fid | checkid)"
     file="${BDB}/${fid}.bm"
     if [ "$(POST control)" = confirm -a -n "$name" -a -f "$file" ]; then
-      order="$(head -n1 "$file" |cut -f3 || printf 1000)"
-      printf '%s\t%s\t%s\n' "$fid" "$(HTML "$name")" "$order" >"${file%.bm}.tmp"
-      tail -n+2 "$file" >>"${file%.bm}.tmp"
-      mv "${file%.bm}.tmp" "$file"
+      sed -ri "1s'^(${fid}\t)[^\t]+(\t.+)$'\1${name}\2';" "$file"
     fi
     REDIRECT "${SCRIPT_NAME}#${fid}"
     ;;
     fi
     REDIRECT "${SCRIPT_NAME}#${fid}"
     ;;