source: wspkg/freebsd/freebsd.ports.sh @ f6d5ca1

Last change on this file since f6d5ca1 was f6d5ca1, checked in by Ting-Wei Lan <lantw44@…>, 3 years ago

Use 'printf' to print non-constant strings in shell scripts

It is unsafe to use 'echo' with strings with variable substitutions.
Different 'echo' implementations may accept different options, and they
can interpret strings with escape characters in different ways. The
behavior of 'printf' is much more consistent so it should be preferred.

  • Property mode set to 100755
File size: 561 bytes
Line 
1#!/bin/sh
2
3msg () {
4        printf '%s\n' "$1" 1>&2
5}
6
7[ -z "$1" ] && msg "Usage: $0 list_file" && exit 1
8: ${FREEBSD_VERSION:="`uname -r | sed 's|^\([0-9]*\).*$|\1|'`"}
9: ${PORTSDIR:="/usr/ports"}
10index="${PORTSDIR}/INDEX-${FREEBSD_VERSION}"
11
12shdir="$(dirname "$0")"
13: ${shdir:="."}
14
15msg "==> FreeBSD version is ${FREEBSD_VERSION}"
16msg "==> FreeBSD ports tree is ${PORTSDIR}"
17msg "==> FreeBSD ports index file is ${index}"
18
19msg "==> Running freebsd.ports.find"
20if "${shdir}/freebsd.ports.find" "$1" "${index}"; then
21        msg "==> Done!"
22else
23        msg "==> Failed"
24        exit 1
25fi
Note: See TracBrowser for help on using the repository browser.