#!/bin/sh -e # Concatanate package files in the installed package database # File names are printed to stderr. ## SYNOPSIS: ## .Nm ## .Op Ar pkg ## .Op Ar file... ## DESCRIPTION: ## .Nm ## outputs the contents of the given package's database files to the standard ## output. The names of the files being printed will also be printed, but to ## stderr. Thus, you can pipe the contents of a file without worrying about ## mixing filenames into that file. ## ## If no package is specified, ## .Nm ## will assume that the package in the current directory is going to be printed. ## ## If no file is specified, ## .Nm ## will print the contents ## .Em build , ## .Em depends , ## .Em sources ## and ## .Em version ## files. parser_definition() { setup REST help:usage -- "usage: ${0##*/} [pkg] [file...]" global_options silent } # shellcheck disable=1091 . cpt-lib [ "$1" ] || { # Usage such as `cpt-cat '' build` is also valid. [ "$#" -gt 1 ] && shift set -- "${PWD##*/}" "$@" } pkg=$1; shift pkg_list "$pkg" >/dev/null [ "$1" ] || set -- build depends sources version # $sys_db and color variables are defined by cpt-lib # shellcheck disable=2154 for file; do [ -f "$sys_db/$pkg/$file" ] || continue printf '%b%s:%b\n' "$colbold" "$file" "$colre" >&2 cat "$sys_db/$pkg/$file" done