Commit 08595072 authored by Natanael Copa's avatar Natanael Copa

ver: make --quiet output suitable for scripting/piping

Do not print version numbers or compare result char when in quiet
mode. This makes the output suitable for be used in scripts or pipes.

For example:

  # Upgrade all packages that matches a given regexp
  apk version --limit '<' --quiet | grep $regexp | apk fix --reinstall

  # Delete all packages that are removed from repository
  apk version --limit '?' --quiet | xargs apk del
parent 9154b8b5
......@@ -130,6 +130,10 @@ static void ver_print_package_status(struct ver_ctx *ictx, struct apk_database *
opstr = apk_version_op_string(r);
if ((ictx->limchars != NULL) && (strchr(ictx->limchars, *opstr) == NULL))
return;
if (apk_verbosity <= 0) {
printf("%s\n", pkg->name->name);
return;
}
snprintf(pkgname, sizeof(pkgname), PKG_VER_FMT,
PKG_VER_PRINTF(pkg));
printf("%-40s%s " BLOB_FMT, pkgname, opstr, BLOB_PRINTF(*latest));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment