base-files: upgrade: add vn and variants
authorYousong Zhou <yszhou4tech@gmail.com>
Tue, 10 Nov 2020 13:30:29 +0000 (21:30 +0800)
committerYousong Zhou <yszhou4tech@gmail.com>
Wed, 11 Nov 2020 13:29:55 +0000 (21:29 +0800)
To be used with in the following pattern

  vn "Remaining: "
  for p in $xx; do
    _vn "$p"
  done
  _v

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
package/base-files/files/lib/upgrade/common.sh

index 2ae83f5bfb545d078efc2fa129b35c1cb46b0d2d..0f251993652f1be254847dcfc8573d28e47acde4 100644 (file)
@@ -63,8 +63,20 @@ ask_bool() {
        [ "$answer" -gt 0 ]
 }
 
+_v() {
+       [ -n "$VERBOSE" ] && [ "$VERBOSE" -ge 1 ] && echo "$*" >&2
+}
+
+_vn() {
+       [ -n "$VERBOSE" ] && [ "$VERBOSE" -ge 1 ] && echo -n "$*" >&2
+}
+
 v() {
-       [ -n "$VERBOSE" ] && [ "$VERBOSE" -ge 1 ] && echo "$(date) upgrade: $@" >&2
+       _v "$(date) upgrade: $@"
+}
+
+vn() {
+       _vn "$(date) upgrade: $@"
 }
 
 json_string() {