source: wspkg/freebsd/freebsd.nopkg-setup.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: 750 bytes
Line 
1#!/bin/sh
2
3ports_file="$1"
4: ${ports_file:="freebsd.ports"}
5
6count=`wc -l < "${ports_file}"`
7tr '/' '_' < "${ports_file}" | paste "${ports_file}" - | (
8        index=1
9        while read -r pkg_name pkg_ports pkg_flavor unused pkg_ports_var unused; do
10                if [ "${pkg_flavor}" != "@" ]; then
11                        pkg_ports_var="${pkg_ports_var}_${pkg_flavor}"
12                        pkg_ports="${pkg_ports} FLAVOR=${pkg_flavor}"
13                fi
14                printf 'WSPKG_PACKAGE_NAME_%-40s != printf '\''\\\\r===> Generating package names (%5d/%5d)'\'' 1>\\&2; $(MAKE) -C ${PORTSDIR}/%-48s -V PKGNAMEPREFIX -V PORTNAME -V PKGNAMESUFFIX \\| tr -d '\''\\\\n'\''%%' \
15                        "${pkg_ports_var}" "${index}" "${count}" "${pkg_ports}"
16                index=$(( ${index} + 1 ))
17        done )
18printf 'WSPKG_PACKAGE_NAME_%-40s != echo 1>\\&2; echo %%' "NULL"
Note: See TracBrowser for help on using the repository browser.